What you`re looking for is a way to configure your plugin, the simplest way to do it is just let the user reopen your classes and change what is need in a initialization file. You could also create a configuration file and have your plugin to load it and configure the pieces that are "configurable", like the model that`s going to be used (in your case, the photos our albuns).
Also, model plugins are usually small and very specific in what they do, your plugin seems to do a lot and this isn't really common when dealing with plugins. Some plugins, like restful_auth, don't even use models, but contain modules that are included in your models, this is better `cos it's easier for someone using your plugin to override your behaviour. You should definitely take a look at the Rails Plugins patterns PDF -> http://peepcode.com/products/rails-2-plugin-patterns - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sun, Feb 22, 2009 at 8:00 PM, Amita Bhatkhande <[email protected]> wrote: > > > My current application is for picture albums. These picture albums are > oraganized/created as per the location. I am just doing it for my > learning purpose. I am trying to make a user management plugin for it. > The basic application worked with no plugin is working fine. > > > Initially I had models like this: > > class Album < ActiveRecord::Base > validates_presence_of :title, :state_id > validates_uniqueness_of :title > has_many :photos > belongs_to :state > end > > class Photo < ActiveRecord::Base > belongs_to :album > end > > class State < ActiveRecord::Base > validates_presence_of :name, :country_id > has_many :albums > belongs_to :country > has_many :users > end > > class Country < ActiveRecord::Base > validates_presence_of :name > validates_uniqueness_of :name > has_many :states > end > > class User < ActiveRecord::Base > validates_presence_of :username, :password_hash, :password_salt, > :role_id > validates_uniqueness_of :username > belongs_to :state > belongs_to :role > before_destroy :dont_delete_admin > end > > class Role < ActiveRecord::Base > validates_presence_of :name > validates_uniqueness_of :name > before_destroy :dont_destroy_admin > has_many :users > end > > > Now for making a plugin I placed my user, role, state, country model in > the vendor/plugins/user_test/lib/app/models directory. However, placing > entire model class in the plugins/models directory may not work. Since > tomorrow the application could be for songs related to particular > location. So for the state model placing this line > plugins/models/state.rb- 'has_many albums' does not make any sense. > > So can I place part of my model definition in the plugin and then one > can modify the albums and state models. This is not a good idea > though... Basically I don't know how should I proceed given this > situation. Any help? > > - > Amita. > > > Maurício Linhares wrote: >> And what`s the problem? >> >> Doing it is quite straightforward after you have the list of timezones >> based on states :) >> >> - >> Maur�cio Linhares >> http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ >> (en) >> >> >> >> On Sat, Feb 21, 2009 at 10:39 PM, Amita Bhatkhande > > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

