Setting up MongoDB and Mongoid in Rails 3.1

November 20, 2011

We need to first set-up the necessary gems:


gem 'mongoid', '~> 2.1'
gem 'bson_ext', '~> 1.4.0'


Then we use mongoid instead of active_record. On your config/application.rb change:


require 'rails/all'


with:


require "action_controller/railtie"
require "action_mailer/railtie"
require "action_resource/railtie"
require "mongoid/railtie"


That’s it. Enjoy!