Ruby on rails 命名错误:未定义的方法“-';零级:零级

Ruby on rails 命名错误:未定义的方法“-';零级:零级,ruby-on-rails,mongodb,mongoid,ruby-1.9.3,Ruby On Rails,Mongodb,Mongoid,Ruby 1.9.3,重新启动vm后,每当我尝试访问任何数据时,都会出现此错误。我使用的是Rails 3.2.3和带有Mongoid的Mongodb。这是我第一个使用MongoDB和Mongoid的项目,我相当肯定这个问题与它有关。Mongo似乎已启动并正在运行。完整的错误消息是: NoMethodError: undefined method `-' for nil:NilClass from /home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gem

重新启动vm后,每当我尝试访问任何数据时,都会出现此错误。我使用的是Rails 3.2.3和带有Mongoid的Mongodb。这是我第一个使用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)>'
NoMethodError: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:在“查询”中
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/context/mongo.rb:201:in'first'
from/home/development/.rvm/gems/ruby-1.9.3-p0@applicationName/gems/mongoid-3.0.6/lib/mongoid/context.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'
来自(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`'

听起来您的mongoid.yml已被覆盖。尝试执行
railsgmongoid:config
并重试。干杯