nobot.checked
nobot.checked

Reputation: 35

ruby on rails with multiple databases ( mongodb, mysql )


I'm planning to use multiple databases (mongodb, mysql) for my project.
And I have no idea with it.
Is there anyone can tell me how to connect mongodb and mysql to rails?
or any references?
Thanks.

-I'm using Ruby 1.9.3 and Rails 3.2

Upvotes: 3

Views: 2460

Answers (1)

ABrowne
ABrowne

Reputation: 1604

You need to setup your rails project with both of the database connections.

Firstly for Mongo, you need to decide which driver wrapper (if you use one) are you going to use. The two common ones are MongoID & MongoMapper. Both do pretty much the same thing and make it easy to interact with Mongo in a similar fashion to ActiveRecord.

To install these you merely install the appropriate gem e.g. for mongomapper you need to run 'gem install mongomapper'

Follow these Railcasts for step by step instructions: MongoMapper or MongoID

Now for mysql, again there is a gem to install, 'gem install mysql', and then follow the instructions on the 'getting started' ruby on rails guide to configure your database files.

Remember for both mongo & mysql you will need to have them installed and running somewhere that it accessible from development environment

Upvotes: 4

Related Questions