Merging two rails apps
I have a main app and a forum app. I wanted to include forums in my main website. I manually copied all files from forum into my main app. I created pr开发者_如何学编程oper routes and copied everything from db/migrate.
Now, I can see that everything is included and it works. But the problem is that whatever was originally stored in my forum apps that is questions and categories are no longer stored in the main app after merging. Its like a new copy.
Is there a better way to merge two rails apps along with stored data? or is there any way i can resolve this issue
You can adapt your forum application as a mountable app, follow this tutorial. I think this could be the best way to do that.
Also you can read pointers in this my previous question to get a general idea on rails engines: Differences between railties and engines in Ruby On Rails 3
Features like forums which are common across web apps can be built using engines which can be easily plugged into rails apps
If you want to share the data between 2 rails apps, you have to have a separate setting in database.yml
and use establish_connection
method inside the forums model in both the rails apps.
Click here to understand how to configure multiple databases in a rails application.
There you go: https://github.com/adamwiggins/yaml_db
Install the plugin
rake db:data:dump
from the old database
rake db:data:load
to the new database. Voila!
精彩评论