I have several apps that share common base models which I am coding into a plugin, but each app may need to add some additional code or override some code in the plugin model.
One of the main differences is that I use multiple database servers in alot of these apps, which is managed by the "use_db" plugin. I am trying to figure out a way to use the "use_db" plugin without hard coding it into the plugin class. I dont want to have to change the plugin every time I install it in a new app.
Can anyone think of a way to create a class inside the rails directories that would be able to extend the plugin model and also be able to specify my "use_db" database... overriding the default rails database. I would also need to be able to add new methods and override methods contained in the plugin model. The model in the plugin contains lots of associations, named_scopes, etc.. so that stuff would still need to be active in the extended model... so I dont think a module would work.
For those not familiar with "use_db" it just allows you to include a prefix which is pulled from database.yml, and the model will use this database. Example:
class Widget < ActiveRecord::Base use_db :prefix => "slave2_" end
this would use the database config "slave2_production" in database.yml for that model if you are in prod mode.
I have tried using "extends" inside the class, creating a subclass, etc.. but nothing seems to give me the behavior I desire. Any ideas guys? Thanks in advance!