2013-07-10 6 views
6

https://github.com/mongoid/mongoid/issues/2894#issuecomment-14903927 を参照して、私は必要な変更をすべて行っています...まだ問題がある...モンゴイド付きのRailsアプリ...(Mongoid :: Errors :: NoSessionConfig): 'default'という名前のセッションで設定が見つかりません

spec_helper.rbファイル

ENV["RAILS_ENV"] ||= 'test' 
require File.expand_path("../../config/environment", FILE) 
require 'rspec/rails' 
require 'rspec/autorun' 
require 'rails/mongoid' 

Gemfile

gem 'rails', '4.0.0' 
gem 'rspec-rails', '~>2.14.0' 
gem 'mongoid', git: 'https://github.com/mongoid/mongoid.git' 
gem 'bson_ext' 

mongoid.yml

キーはの内にある必要があります:
development: 
    sessions: 
    default: 
     database: mongo_demo_development 
    hosts: 
     - localhost:27017 
    options:   
options: 

test: 
    sessions: 
    default: 
     database: mongo_demo_test 
     hosts: 
     - localhost:27017 
     options: 
     consistency: :strong  
     max_retries: 1 
     retry_interval: 0 

には、以下の

/home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/sessions/factory.rb:27:in create': (Mongoid::Errors::NoSessionConfig) 
Problem: 
No configuration could be found for a session named 'default'. 
Summary: 
When attempting to create the new session, Mongoid could not find a session configuration for the name: 'default'. This is necessary in order to know the host, port, and options needed to connect. 
Resolution: 
Double check your mongoid.yml to make sure under the sessions key that a configuration exists for 'default'. If you have set the configuration programatically, ensure that 'default' exists in the configuration hash. 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/sessions.rb:137:inwith_name' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/sessions.rb:390:in __session__' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/sessions.rb:227:inmongo_session' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/sessions.rb:171:in collection' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/contextual/mongo.rb:265:ininitialize' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/contextual.rb:51:in new' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/contextual.rb:51:increate_context' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/contextual.rb:34:in context' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/contextual.rb:18:inlast' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/bundler/gems/mongoid-d52c33bce36a/lib/mongoid/findable.rb:130:in last' 
from /home/nikunj/Practice/mongo_demo/app/rules/myrule_book.rb:5:inclass:Myrule_Book' 
from /home/nikunj/Practice/mongo_demo/app/rules/myrule_book.rb:3:in <top (required)>' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:inload' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in block in load_file' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:innew_constants_in' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in load_file' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:inrequire_or_load' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in load_missing_constant' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:inconst_missing' 
from /home/nikunj/Practice/mongo_demo/config/environments/development.rb:30:in block in <top (required)>' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:24:inclass_eval' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:24:in configure' 
from /home/nikunj/Practice/mongo_demo/config/environments/development.rb:1:in' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in require' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inblock in require' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inrequire' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/engine.rb:591:in block (2 levels) in <class:Engine>' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/engine.rb:590:ineach' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/engine.rb:590:in block in <class:Engine>' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:30:ininstance_exec' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:30:in run' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:55:inblock in run_initializers' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:150:in block in tsort_each' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:183:inblock (2 levels) in each_strongly_connected_component' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:210:in block (2 levels) in each_strongly_connected_component_from' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:219:ineach_strongly_connected_component_from' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:209:in block in each_strongly_connected_component_from' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:44:ineach' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:44:in tsort_each_child' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:203:ineach_strongly_connected_component_from' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:182:in block in each_strongly_connected_component' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:180:ineach' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:180:in each_strongly_connected_component' 
from /home/nikunj/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/tsort.rb:148:intsort_each' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/initializable.rb:54:in run_initializers' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/application.rb:215:ininitialize!' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in method_missing' 
from /home/nikunj/Practice/mongo_demo/config/environment.rb:5:in' 
from /home/nikunj/Practice/mongo_demo/config.ru:3:in require' 
from /home/nikunj/Practice/mongo_demo/config.ru:3:inblock in ' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/builder.rb:55:in instance_eval' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/builder.rb:55:ininitialize' 
from /home/nikunj/Practice/mongo_demo/config.ru:in new' 
from /home/nikunj/Practice/mongo_demo/config.ru:in' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/builder.rb:49:in eval' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/builder.rb:49:innew_from_string' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/builder.rb:40:in parse_file' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/server.rb:277:inbuild_app_and_options_from_config' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/server.rb:199:in app' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/commands/server.rb:48:inapp' 
from /home/nikunj/.rvm/gems/[email protected]/gems/rack-1.5.2/lib/rack/server.rb:314:in wrapped_app' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/commands/server.rb:75:instart' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/commands.rb:78:in block in <top (required)>' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/commands.rb:73:intap' 
from /home/nikunj/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0/lib/rails/commands.rb:73:in <top (required)>' 
from bin/rails:4:inrequire' 
from bin/rails:4:in `' 
+0

こんにちは、Rails.env = 'テスト'ともう一度チェックしてください – Amar

+1

問題を解決しましたか? – cortex

+0

Gemfileのローカルから宝石をロードしようとしていますか? – parov

答えて

1

を確認してください、私は同じ問題とエラーメッセージを持っていた - YML設定ファイルがロードされなかったので、私の場合はそれが発生しました。私は、設定/ application.rbに以下の行

Mongoid.load!('config/mongoid.yml') 

を追加し、それが問題

0

が問題かもしれ解決あなたがmongoid宝石のバージョンを言及did't、宝石のファイルです。 in gem file gem "mongoid"からgem "mongoid" , '~> 4.0.2'に変更し、バンドルインストール再起動サーバーとコンソールを実行します。

関連する問題