ruby-on-rails – 独角兽在资产预编译期间触发mongoid错误

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 独角兽在资产预编译期间触发mongoid错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个rails应用程序使用Mongoid 3运行在Heroku.我刚刚更新它使用Unicorn.当我尝试部署到Heroku我得到以下错误
Running: rake assets:precompile
rake aborted!
   undefined method `match' for nil:NilClass
   /tmp/build_3nnbzpfmnjpns/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.21/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize'

完整的堆栈跟踪可以在http://pastebin.com/8YcJHEmS找到

但是,如果我从我的Gemfile中删除Unicorn,则资产编译成功.查看Mongoid代码,我可以看到,当mongoid.yml文件被解析时,会发生错误,但是我无法弄清楚Unicorn为什么会导致失败.
我的mongoid.yml文件如下所示:

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

和我的宝石:

source 'https://rubygems.org'
ruby '1.9.3'

gem 'rails','3.2.11'
gem 'thin'

group :assets do
  gem 'sass-rails','~> 3.2'
  gem 'coffee-rails','~> 3.2'
  gem 'uglifier','>= 1.0.3'
  gem "twitter-bootstrap-rails",'>=2.1.8'
  gem "bootstrap_form"

end

gem "jquery-rails"
gem 'jquery-ui-rails',"3.0.1"

gem 'newrelic_rpm'
gem "httparty"
gem "resque"
gem "resque-loner"
gem "unicorn","4.4.0"
gem "mongoid","~> 3.0.0"
gem "mongo","~> 1.7.0"
gem "bson","~> 1.7"
gem "bson_ext","~> 1.7"
gem 'less-rails',"~> 2.2"
gem 'therubyracer','>= 0.11.1'
gem 'libv8','~> 3.11.8'
gem 'devise','~> 2.1.2'
gem 'devise_invitable','~> 1.0.0'
gem 'bootstrap_form'
gem 'font-awesome-rails'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'kaminari'
gem 'mongoid_search'

你有什么想法是什么原因造成的?

解决方法

轨3:

尝试在预编译资产时关闭应用初始化:

# config/application.rb
config.assets.initialize_on_precompile = false

该行应该已经在那里发表了评论.

原文链接:/ruby/271026.html

猜你在找的Ruby相关文章