Web Development | Ruby on Rails | React.js

Mongo, Mongoid and Rails 4.1

I typically forget to set the --skip-active-record when creating a new app, so this is the little kabuki dance you need to perform to get Mongoid to play nice with a freshly created Rails 4.1 project.

  1. Add mongoid to your Gemfile:
    gem 'mongoid', '~> 4.0.0'

  2. Generate your mongoid.yml configuration file:
    rails g mongoid:config

  3. Remove the sqlite gem now from your Gemfile:
    gem 'sqlite3'

  4. Delete database.yml

  5. Remove any lines that reference active_record from your environment files:

# development.rb
config.active_record.migration_error = :page_load

# production.rb
config.active_record.dump_schema_after_migration = false

6. Change this in your application.rb:

require 'rails/all'


require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"