gpt4 book ai didi

ruby-on-rails - 使用 Mongodb 让 Rails 在 Heroku 上工作

转载 作者:行者123 更新时间:2023-12-01 22:42:31 26 4
gpt4 key购买 nike

我已经下载了一个开源代码ribbot .我是 Ruby 和 Rails 的新手,但我已经设置了我的环境并且能够让这段代码在我的本地机器上运行。

我想使用 Heroku 作为我的服务器基础解决方案。我把这个应用程序推到了 Heroku。 Heroku 似乎告诉我该应用程序运行良好,但我不断通过开源代码重定向到错误页面;它不会在我的本地机器上这样做。我怀疑它与Mongo有关。我已经为 Heroku 下载了 MongoHQ 上的插件,但仍然遇到这个问题。我知道这段代码使用了 mongoid:

2012-04-16T19:06:47+00:00 app[web.1]: localhost:11211 failed (count: 2)
2012-04-16T19:06:47+00:00 app[web.1]:
2012-04-16T19:06:47+00:00 app[web.1]:
2012-04-16T19:06:47+00:00 app[web.1]: Started GET "/" for 208.124.140.154 at 2012-04-16 19:06:47 +0000
2012-04-16T19:06:47+00:00 app[web.1]: allow_dynamic_fields is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: autocreate_indexes is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: identity_map_enabled is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: include_root_in_json is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: include_type_for_serialization is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: max_retries_on_connection_failure is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: parameterize_keys is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: scope_overwrite_exception is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: persist_in_safe_mode is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: preload_models is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: raise_not_found_error is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: skip_version_check is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: time_zone is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: use_utc is not a valid option for Mongo::Connection
2012-04-16T19:06:47+00:00 app[web.1]: timestamped_migrations is not a valid option for Mongo::Connection
2012-04-16T19:06:50+00:00 app[web.1]:
2012-04-16T19:06:50+00:00 app[web.1]: Mongo::ConnectionFailure (Failed to connect to a master node at localhost:27017):
2012-04-16T19:06:50+00:00 app[web.1]: app/controllers/application_controller.rb:19:in `current_forum'
2012-04-16T19:06:50+00:00 app[web.1]: app/controllers/application_controller.rb:40:in `require_current_forum!'
2012-04-16T19:06:50+00:00 app[web.1]:
2012-04-16T19:06:50+00:00 app[web.1]:
2012-04-16T19:06:50+00:00 app[web.1]: cache: [GET /] miss
2012-04-16T19:06:50+00:00 app[web.1]: Processing by PostsController#index as HTML
2012-04-16T19:06:50+00:00 app[web.1]: Completed 500 Internal Server Error in 2997ms
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_request.text.erb (0.2ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_session.text.erb (0.2ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_environment.text.erb (23.9ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (0.1ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-04-16T19:06:50+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification_rails3-1.2.0/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (26.8ms)
2012-04-16T19:06:50+00:00 app[web.1]:
2012-04-16T19:06:50+00:00 app[web.1]: Sent mail to barmstrong@gmail.com (274ms)
2012-04-16T19:06:50+00:00 heroku[router]: GET impact-project.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=3832ms status=500 bytes=728
2012-04-16T19:06:51+00:00 app[web.1]: localhost:11211 failed (count: 3)
2012-04-16T19:06:51+00:00 app[web.1]: cache: [GET /favicon.ico] miss, store
2012-04-16T19:06:51+00:00 app[web.1]: [2012-04-16 19:06:51] ERROR NoMethodError: undefined method `each' for nil:NilClass
2012-04-16T19:06:51+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/handler/webrick.rb:71:in `service'
2012-04-16T19:06:51+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-04-16T19:06:51+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-04-16T19:06:51+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-04-16T19:06:51+00:00 heroku[router]: GET impact-project.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=517ms status=500 bytes=337

最佳答案

如果您在 Heroku 中安装了 MongoHQ 附加组件,它会创建一个 MONGOHQ_URL 环境变量,您的 Rails 应用程序可以使用该变量连接到数据库。看起来你的 config/mongoid.yml 配置不正确。这是 Heroku 和 MongoHQ 的工作示例:

development:
host: localhost
database: yourapp_dev

test:
host: localhost
database: yourapp_test

# set these environment variables on your prod server
production:
uri: <%= ENV['MONGOHQ_URL'] %>

希望这对您有所帮助!

关于ruby-on-rails - 使用 Mongodb 让 Rails 在 Heroku 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10180169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com