2013-06-28 35 views
0

我在Heroku它使用mongoid和delayed_job的應用程序,我已經從1.9.2改爲紅寶石版本1.9.3,我得到一個錯誤Heroku的零級錯誤,同時節省對象

undefined method `match' for nil:NilClass 

而我嘗試保存對象mongoid數據的基礎上我mongoid.yaml文件看起來像

production: 
    sessions: 
    default: 
     uri: <%= ENV['MONGOHQ_URL'] %> 
     options: 
     skip_version_check: true 
     safe: true 

痕跡這裏

NoMethodError: undefined method `match' for nil:NilClass 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:103:in `new' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:103:in `parse' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:62:in `create_session' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:43:in `default' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:109:in `default' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:378:in `__session__' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:213:in `mongo_session' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:157:in `collection' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:25:in `collection' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/operations.rb:27:in `collection' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/operations/insert.rb:27:in `block in persist' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/insertion.rb:25:in `block (2 levels) in prepare' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:403:in `_run__4034630009416245289__create__685777988298500290__callbacks' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_create_callbacks' 

... 2 levels... 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/insertion.rb:24:in `block in prepare' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:403:in `_run__4034630009416245289__save__685777988298500290__callbacks' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_save_callbacks' 
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/callbacks.rb:114:in `run_callbacks' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/insertion.rb:23:in `prepare' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence/operations/insert.rb:26:in `persist' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence.rb:50:in `insert' 
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.13/lib/mongoid/persistence.rb:79:in `save' 
from (irb):2 
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start' 
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start' 
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>' 
from script/rails:6:in `require' 

任何人都可以幫助我?在此先感謝

+0

什麼是追溯報告?發生此錯誤的文件是什麼? – zeantsoi

+0

我已經更新了回溯的問題 –

+0

嗯...根據你的回溯,無論出於何種原因,看起來Heroku認爲你在Ruby 1.9.1上。任何想法,爲什麼這可能是?這個答案可能有所幫助:http://stackoverflow.com/questions/11943470/heroku-not-using-the-specified-ruby-1-9-3 – zeantsoi

回答

1

錯誤發生,因爲此方法https://github.com/mongoid/mongoid/blob/v3.0.13/lib/mongoid/sessions/mongo_uri.rb#L49的輸入參數爲零。

進一步查看調用堆棧以查明該字符串來自哪裏(請參閱https://github.com/mongoid/mongoid/blob/v3.0.13/lib/mongoid/sessions/factory.rb#L103),它看起來像您的uri配置參數爲零。 uri鍵存在但是空的,所以你可以通過運行heroku config來檢查你的MONGOHQ_URL配置參數。這應該是由MongoHQ插件設置的。

堆棧跟蹤中的Ruby 1.9.1路徑沒有什麼可擔心的。請參閱Why Do Heroku Stack Traces indicate Ruby 1.9.1 is in use?

+0

是的,你是對的MongoHQ_URL是零 –

+0

我該如何設置這個uri? –

+0

這應該在添加MongoHQ插件時自動配置。您可以使用'heroku addons'檢查插件是否仍然附加到您的應用程序,並且您需要使用'heroku config:set KEY = VALUE'手動設置配置參數。您必須通過Heroku網站上的應用程序的插件頁面找到適合您插件的正確URL。 – Steve