使用mongoid
Active Record迁移到mongoid
1. 修改文件:config/application.rb
require 'rails/all' 修改为
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
注释 config.active_record.whitelist_attributes = true
2. 修改文件:config/environments/development.rb,config/environments/test.rb
注释 config.active_record.mass_assignment_sanitizer = :strict
注释 config.active_record.auto_explain_threshold_in_seconds = 0.5
3. 删除文件:config/database.yml
4. 修改Gemfile
添加 gem 'mongoid'
添加 gem 'bson_ext'
5. 创建配置
$ rails g mongoid:config
家教呢:www.jiajiaone.com