Rails ruby-china 本地开发遇到的问题

yorzi · 2011年11月23日 · 最后由 yorzi 回复于 2012年02月04日 · 5958 次阅读

打算闲余时间给 ruby-china 贡献点 code,顺便也学习一下 MongoDB 相关的应用实践,但是现在代码在本地跑不起来,由于之前没有做过 Mongoid/MongoDB 相关的 Rails 项目,所以不清楚到底哪里出了问题..

问题: 按照文档做好相关配置之后,rails s 可以正常启动 server

但是访问 app 的时候出现如下 log: /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongo-1.3.1/lib/mongo/db.rb:506:in `command': Database command 'findandmodify' failed: {"errmsg"=>"No matching object found", "ok"=>0.0} (Mongo::OperationFailure)

补充: 在运行rake assets:precompile./script/resque start的时候也出现以上相同的错误。

请求帮助,Thanks!

能把错误日志全部贴上来吗?一截看不清上下文

MongoDB 什么版本?

@Rei

andy@Wang-Andys-MacBook-Pro~/github.workspace/ruby-china (master):rails s
/Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local/git/bin in PATH, mode 040777
/Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/bundler-1.0.21/lib/bundler.rb:209: warning: Insecure world writable dir /usr/local/git/bin in PATH, mode 040777
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongo-1.3.1/lib/mongo/db.rb:506:in `command': Database command 'findandmodify' failed: {"errmsg"=>"No matching object found", "ok"=>0.0} (Mongo::OperationFailure)
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongo-1.3.1/lib/mongo/collection.rb:532:in `find_and_modify'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid_auto_increment_id-0.2.2/lib/mongoid_auto_increment_id.rb:10:in `generate_id'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid_auto_increment_id-0.2.2/lib/mongoid_auto_increment_id.rb:34:in `as_document'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/operations/insert.rb:27:in `block in persist'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/insertion.rb:26:in `block (3 levels) in prepare'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:390:in `_run_create_callbacks'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/insertion.rb:25:in `block (2 levels) in prepare'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:390:in `_run_save_callbacks'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/insertion.rb:24:in `block in prepare'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/insertion.rb:22:in `tap'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/insertion.rb:22:in `prepare'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence/operations/insert.rb:26:in `persist'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:44:in `insert'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:149:in `upsert'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:170:in `block (2 levels) in create'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:170:in `tap'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:170:in `block in create'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:273:in `creating'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/mongoid-2.2.4/lib/mongoid/persistence.rb:169:in `create'
    from /Users/andy/github.workspace/ruby-china/app/models/site_config.rb:53:in `save_default'
    from /Users/andy/github.workspace/ruby-china/config/initializers/default_site_configs.rb:7:in `<top (required)>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `block in load'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/engine.rb:555:in `each'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/engine.rb:555:in `block in <class:Engine>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/andy/github.workspace/ruby-china/config/environment.rb:6:in `<top (required)>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
    from /Users/andy/github.workspace/ruby-china/config.ru:4:in `block in <main>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/andy/github.workspace/ruby-china/config.ru:1:in `new'
    from /Users/andy/github.workspace/ruby-china/config.ru:1:in `<main>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/builder.rb:40:in `eval'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/server.rb:200:in `app'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/commands/server.rb:46:in `app'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/rack-1.3.5/lib/rack/server.rb:252:in `start'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/commands.rb:54:in `block in <top (required)>'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap'
    from /Users/andy/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/railties-3.1.1/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

#2 楼 @huacnlee

db version v1.4.3, pdfile version 4.5
git hash: 47ffbdfd53f46edeb6ff54bbb734783db7abc8ca
sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_37

#4 楼 @yorzi 或许你可以实施 1.8+ 就没问题了

#4 楼 @yorzi 1.4.3 太低了,升最新版吧 findAndModify 的 upsert 需要 1.5.4+ http://www.mongodb.org/display/DOCS/findAndModify+Command

@huacnlee @Rei - 刚意识到可能是 MongoDB 版本太低了。。。Re-installing.. Thanks!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号