You can use Mysql and Mongodb in one application.
1. Create a rails app using mysql.
2. Next, add following to your Gemfile
, and run bundle install
:
gem "mongoid", "~> 2.3"
gem "bson_ext", "~> 1.4"
Now, you’re almost ready to go, but you still need some configuration info. Generate config/mongo.yml
by running:
rails generate mongoid:config
This will create a mongo.yml where you can configure it to use as per the development environment.
Configure Rails’ model generator. Inside of the Application class (config/application.rb
) add:
config.generators do |g|
g.orm :mongoid
end
This will allow you to use the
rails generate model
command with Mongoid.For using Mongomapper instead of Mongoid refer,
For more details regarding usage of Mongoid refer,