简体   繁体   English

NoMethodError:未定义的方法` - '表示nil:NilClass

[英]NoMethodError: undefined method `-' for nil:NilClass

After a reboot of my vm, any time I attempt to access any data I get this error. 重新启动我的虚拟机后,每当我尝试访问任何数据时,都会收到此错误。 I am using Rails 3.2.3, and Mongodb w/ Mongoid. 我正在使用Rails 3.2.3和Mongodb w / Mongoid。 This is my first project using MongoDB and Mongoid and I am fairly certain the issue has something to do with it. 这是我使用MongoDB和Mongoid的第一个项目,我相当肯定这个问题与它有关。 It appears that Mongo is started and running. 似乎Mongo已经开始运行了。 The full error message is: 完整的错误消息是:

NoMethodError: undefined method `-' for nil:NilClass
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/cluster.rb:118:in `block in refresh'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/cluster.rb:125:in `each'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/cluster.rb:125:in `refresh'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/cluster.rb:78:in `nodes'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/cluster.rb:187:in `with_secondary'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/session/context.rb:104:in `with_node'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/session/context.rb:43:in `query'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/moped-1.2.5/lib/moped/query.rb:109:in `first'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/mongoid-3.0.6/lib/mongoid/contextual/mongo.rb:201:in `first'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/mongoid-3.0.6/lib/mongoid/contextual.rb:18:in `first'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/mongoid-3.0.6/lib/mongoid/finders.rb:119:in `first'
from (irb):3
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'

Sounds like your mongoid.yml has been overwritten. 听起来像你的mongoid.yml已被覆盖。 Try doing a rails g mongoid:config and trying again. 尝试做一个rails g mongoid:config并再次尝试。 Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM