我有一个在 Heroku 上运行的使用 Mongoid 3 的 rails 应用程序。我刚刚更新它以使用独角兽。当我尝试将其部署到 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
还有我的 Gemfile :
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'
你知道是什么原因造成的吗?