Reputation: 14671
I have several active record models in a rails app and I would like to extract these models into a gem so that I can easily use them in several web apps. The process seems pretty straight forward, except for passing along the configuration for the models. Do I:
Upvotes: 2
Views: 1639
Reputation: 19249
You should use the host rails app's database config. Your plugin or gem should contain just the database migrations, and a rake task to run them from the host rails app (e.g. myplugin:db:migrate
)
If your models need some other configuration file, you should create a rake task (e.g. myplugin:install
) to copy it to your host app's config directory. (This task can call the db:migrate task automatically as well.)
Upvotes: 3
Reputation: 655
Why do you want to embed the database.yml file inside the gem? Each rails application should use it's own database.yml
I would put all the models into a plugin and include that in each rails application that needs the models.
Upvotes: 1