2012-12-03 16 views
6

Sau khi khởi động lại vm của tôi, bất cứ lúc nào tôi cố gắng truy cập vào bất kỳ dữ liệu nào tôi nhận được lỗi này. Tôi đang sử dụng Rails 3.2.3, và Mongodb w/Mongoid. Đây là dự án đầu tiên của tôi sử dụng MongoDB và Mongoid và tôi khá chắc chắn vấn đề có liên quan đến nó. Dường như Mongo được bắt đầu và chạy. Thông báo lỗi đầy đủ là:NoMethodError: phương thức chưa xác định `- 'cho nil: NilClass

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

Trả lời

4

Âm thanh như mongoid.yml của bạn đã bị ghi đè. Hãy thử thực hiện rails g mongoid:config và thử lại. Chúc mừng.

+0

Đây là nó. Bạn là một người thiên tài, cảm ơn bạn. –