Heroku预编译资产失败

时间:2013-09-24 03:30:21

标签: ruby-on-rails mongodb heroku mongoid

我在解决以下问题时遇到了困难,并弄清楚为什么我的资产无法在slug编译中进行预编译...奇怪的是,当我检查实时日志时,资产在运行时编译良好...任何想法?它是否尝试连接数据库?

Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   undefined method `match' for nil:NilClass
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions/factory.rb:104:in `new'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions/factory.rb:104:in `parse'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions/factory.rb:62:in `create_session'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions/factory.rb:43:in `default'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/sessions.rb:109:in `default'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid.rb:129:in `default_session'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.4/lib/mongoid/railtie.rb:131:in `block (2 levels) in <class:Railtie>'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `call'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/config/environment.rb:5:in `<top (required)>'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
   /tmp/build_27348f41-abb7-46f0-a7ac-6f66bf0feff7/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
   Tasks: TOP => environment
   (See full trace by running task with --trace)

2 个答案:

答案 0 :(得分:6)

检查资产预编译是否需要在运行期间访问ENV变量。从堆栈跟踪中很难说清楚,但这可能是一个很好的资源来查看:https://devcenter.heroku.com/articles/rails-asset-pipeline

基本上,您可以在heroku上启用user-env-compile实验室功能,以便在预编译期间让您的应用实例访问ENV vars。

 heroku labs:enable user-env-compile -a myapp

有关此处的更多信息:https://devcenter.heroku.com/articles/labs-user-env-compile

答案 1 :(得分:0)

我刚刚添加了Unicorn,我将以下内容添加到我的application.rb中,并且能够预编译:

config.assets.initialize_on_precompile = false