2

I am Using Rails 3.0.3 Application. In My Application I need to interact with multiple databases dynamically at run time.

Requirement:

1] In future I may be need to add some more databases. It should support that requirement.

1 Answer 1

2

To interact with multiple databases you can use Connection Ninja. Please follow this link. There you can see that works even with rails 3, just install it using:

gem install connection_ninja

Hope that helps,

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for reply. But once i generated model. I have mentioned in migration file like require 'connection_ninja' use_connection_ninja(database_name). Now i run rake db:migrate then it is throwing error like undefined method `use_connection_ninja' for main:Object. what i need to do now?
Please note that you must use it not in migrations but in Models: class MyModel < ActiveRecord::Base use_connection_ninja(:other_database) end There is a good abstraction to use it along many models in the link I mentioned to you. Hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.