How to properly configure rails 4 and mangoid?

I have quite a lot of problems getting Mongo and 4 rails to play beautifully, currently my gemfile looks like

source 'https://rubygems.org' ruby '2.0.0' gem 'rails', '4.0.0' gem 'sass-rails', '~> 4.0.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'jbuilder', '~> 1.2' gem "zeus", "~> 0.13.3" gem "thin", "~> 1.6.0" gem "pry", "~> 0.9.12.2" gem "rspec-rails", "~> 2.14.0" gem "font-awesome-rails" gem "haml", "~> 4.0.3" gem "skrollr-rails", "~> 0.6.12" gem "zurb-foundation", "~> 4.3.2" gem 'rails_12factor', group: :production gem "bourbon", "~> 3.1.8" gem "gon", "~> 4.1.1" gem "d3-rails" gem 'underscore-rails' gem 'mongoid', github: 'mongoid/mongoid' group :doc do gem 'sdoc', require: false end 

my mongoid.yml looks like

 development: sessions: default: database: mongoid hosts: - localhost:27017 options: options: production: sessions: default: url: <%= ENV['MONGOHQ_URL'] %> options: consistency: :strong max_retries: 1 retry_interval: 0 

and I get the error below

 [ jd@mbp ~/Dropbox/honeybadgerconsulting/appcellerator/maturity_assessment (master *)]$ rails s /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- rack/mongoid (LoadError) from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/bundler/gems/mongoid-9296c9372579/lib/mongoid.rb:33:in `<top (required)>' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in `require' from /Users/jd/Dropbox/honeybadgerconsulting/appcellerator/maturity_assessment/config/application.rb:10:in `<top (required)>' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap' from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>' 

when i try to start rails server.

I have one model defined just to verify that mongo is working correctly

 class Project include Mongoid::Document field :name, type: String field :status, type: String end 

and my application.rb application has the following additions that I saw on the seemingly incomplete educational field of the Internet.

 require File.expand_path('../boot', __FILE__) require "action_controller/railtie" require "action_mailer/railtie" require "sprockets/railtie" require "rails/test_unit/railtie" 

Any help as to which direction to take would be greatly appreciated.

+6
source share
1 answer

The problem is resolved. There was an error https://github.com/mongoid/mongoid/pull/3368 , now it’s good.

+1
source

Source: https://habr.com/ru/post/957470/


All Articles