簡體   English   中英

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

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

重新啟動我的虛擬機后,每當我嘗試訪問任何數據時,都會收到此錯誤。 我正在使用Rails 3.2.3和Mongodb w / Mongoid。 這是我使用MongoDB和Mongoid的第一個項目,我相當肯定這個問題與它有關。 似乎Mongo已經開始運行了。 完整的錯誤消息是:

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)>'

聽起來像你的mongoid.yml已被覆蓋。 嘗試做一個rails g mongoid:config並再次嘗試。 干杯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM