Я недавно пытался настроить mongoid с помощью бесплатной учетной записи mongohq на heroku … Эта информация верна по состоянию на 28 февраля 2012 года.
Для нетерпеливых (я просто хочу заставить это работать)
mongoid.yml
production: uri: <%= ENV['MONGOLAB_URI'] %>
Gemfile
gem 'bson', '1.3.1' gem 'bson_ext', '1.3.1' gem 'mongoid', '2.0.2'
Для тех, кто хочет более подробно (у меня похожая проблема, как мне устранить неполадки
Чтобы определить переменные среды heroku, сделайте это:
$ heroku config
и результаты должны содержать следующую строку:
... MONGOLAB_URI => mongodb://heroku_app928349384:[email protected]:31087/heroku_appapp928349384 ...
Важно отметить, что говорит левая линия. По всему интернету (как здесь, на SO, они неправильно называют ENV как MONGOHQ_URI. Так что обновите mongoid.yml так:
Кроме того, кажется, что разные версии mongoid работают только с определенными версиями mongodb. Я начал копаться в Google, чтобы найти версии, которые кажутся совместимыми.
Трассировка стека с неправильным URI:
production: uri: <%= ENV['MONGOLAB_URI'] %>
Даст что-то вроде
2012-02-28T12:49:46+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure) 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `new' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in `from_uri' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config/database.rb:86:in `master' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config/database.rb:19:in `configure' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config.rb:114:in `from_hash' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/config.rb:342:in `configure_databases' 2012-02-28T12:49:46+00:00 app[web.1]: from (eval):2:in `from_hash' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.2/lib/mongoid/railtie.rb:64:in `block in <class:Railtie>' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `instance_exec' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `run' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:50:in `block in run_initializers' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `run_initializers' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `each' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:134:in `initialize!' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>' 2012-02-28T12:49:46+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require' 2012-02-28T12:49:46+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require' 2012-02-28T12:49:46+00:00 app[web.1]: from config.ru:3:in `block (3 levels) in <main>' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `eval' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `new' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `map' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `block in <main>' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `new' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-28T12:49:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new' 2012-02-28T12:49:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner. 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load' 2012-02-28T12:49:46+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>' 2012-02-28T12:49:47+00:00 heroku[web.1]: Process exited with status 1 2012-02-28T12:49:47+00:00 heroku[web.1]: State changed from starting to crashed
Трассировка стека с неверной версией монго / монгоид / бсон:
Starting process with command `thin -p 4644 -e production -R /home/heroku_rack/heroku.ru start` 2012-02-27T22:50:46+00:00 app[web.1]: /app/app/models/expression.rb:2:in `<class:Expression>': uninitialized constant Expression::Mongoid (NameError) 2012-02-27T22:50:46+00:00 app[web.1]: from /app/app/models/expression.rb:1:in `<top (required)>' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:137:in `each' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:137:in `block in eager_load!' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:135:in `eager_load!' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/engine.rb:135:in `each' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:108:in `eager_load!' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `instance_exec' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:25:in `run' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:50:in `block in run_initializers' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `each' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/initializable.rb:49:in `run_initializers' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:134:in `initialize!' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>' 2012-02-27T22:50:46+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `eval' 2012-02-27T22:50:46+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require' 2012-02-27T22:50:46+00:00 app[web.1]: from config.ru:3:in `block (3 levels) in <main>' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `new' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `map' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `new' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `block in <main>' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval' 2012-02-27T22:50:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new' 2012-02-27T22:50:46+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load' 2012-02-27T22:50:46+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>' 2012-02-27T22:50:47+00:00 heroku[web.1]: Process exited with status 1 2012-02-27T22:50:47+00:00 heroku[web.1]: State changed from starting to crashed 2012-02-27T22:50:48+00:00 heroku[router]: Error H10 (App crashed) -> POST newsfilter.heroku.com/_heroku/console dyno= queue= wait= service= status=503 bytes=