Rails 4 + Mongoid setup (updated)
Note:
You should always create your Rails application using the flag --skip-active-record
, but if your forget it or the damage is done, you can use this workaround.
Update:
Mongoid 4.0.0 has been released!
In your Gemfile
replace the following lines:
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
With:
gem 'mongoid', '~> 4.0.0'
gem 'bson_ext'
Then execute:
bundle update
bundle exec rails g mongoid:config
Now, in config/application.rb
file replace the line:
require 'rails/all'
With:
require "action_controller/railtie"
require "action_mailer/railtie"
# require "active_resource/railtie"
require "sprockets/railtie"
If you want to use ActiveResource
, you will need to require the gem and then comment out the commented line.
And, in config/environments/development.rb
, comment the line:
# config.active_record.migration_error = :page_load
Written by Pablo Torrecilla
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#