作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 Rails Mountable App 并添加了“mongoid”和“rspec” gem。如果我现在尝试运行我的规范,我会收到以下错误:
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.
Mongoid.load!(Rails.root.join("config", "mongoid.yml"))
线到
spec_helper.rb
一切正常。
development:
sessions:
default:
database: dummy_development
hosts:
- localhost:27017
options:
options:
test:
sessions:
default:
database: dummy_test
hosts:
- localhost:27017
options:
consistency: :strong
max_retries: 1
retry_interval: 0
gem 'rails', '~> 3.2.12'
gem 'mongoid', '~> 3.1'
gem 'rspec-rails', '~> 2.13'
最佳答案
你可能错过了 require 'rails/mongoid'
在您的 spec_helper.rb 文件中。
这里有人遇到同样的问题 https://github.com/mongoid/mongoid/issues/2894#issuecomment-14903927
尝试添加那个要求,应该可以解决它。
关于rails-engines - Rails 引擎 + Mongoid : No configuration could be found for a session named 'default' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15354936/
我是一名优秀的程序员,十分优秀!