Usually, plugins do it by using polymorphic associations, so they don't need to know in advance the real class that's going to be referenced.
- Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Feb 25, 2009 at 1:21 AM, Amita Bhatkhande <[email protected]> wrote: > > Thanks for the link.. I am going through the guide. > However, I am still wondering how can I include associations (has_many > and belongs_to methods) in my plugin. Because I do not know what will be > the model/table name used by user to associate my plugin's model to.. > > e.g.: for one application it could be user- :has_many photos or for > another application- user :has_many songs . > > Thanks, > Amita. > > > Maurício Linhares wrote: >> 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 > > -- > 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 -~----------~----~----~----~------~----~------~--~---

