我的应用程序使用devise和mongo所以我添加了mongohq作为插件但是当它尝试在heroku上打开我的应用程序时出现此错误:
应用程序中发生错误,您的页面无法执行 提供服务。请稍后再试。
如果您是应用程序所有者,请查看日志以获取详细信息。
heroku日志:
2014-05-23T14:58:38.601715+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.10.1/lib/mongo/mongo_client.rb:422:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
2014-05-23T14:58:38.580675+00:00 app[web.1]: There is a configuration error with the current mongoid.yml.
2014-05-23T14:58:38.580684+00:00 app[web.1]:
2014-05-23T14:58:38.580686+00:00 app[web.1]: Problem:
2014-05-23T14:58:38.580688+00:00 app[web.1]: No sessions configuration provided.
2014-05-23T14:58:38.580690+00:00 app[web.1]: Summary:
2014-05-23T14:58:38.580692+00:00 app[web.1]: Mongoid's configuration requires that you provide details about each session that can be connected to, and requires in the sessions config at least 1 default session to exist.
2014-05-23T14:58:38.580693+00:00 app[web.1]: Resolution:
2014-05-23T14:58:38.580695+00:00 app[web.1]: Double check your mongoid.yml to make sure that you have a top-level sessions key with at least 1 default session configuration for it. You can regenerate a new mongoid.yml for assistance via `rails g mongoid:config`.
2014-05-23T14:58:38.580697+00:00 app[web.1]:
2014-05-23T14:58:38.580698+00:00 app[web.1]: Example:
2014-05-23T14:58:38.580700+00:00 app[web.1]: development:
2014-05-23T14:58:38.580701+00:00 app[web.1]: sessions:
2014-05-23T14:58:38.580703+00:00 app[web.1]: default:
2014-05-23T14:58:38.580704+00:00 app[web.1]: database: mongoid_dev
这是我的mongoid.yml:
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: healthy_grocery_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false
# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual
# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Configuration for whether or not to allow access to fields that do
# not have a field definition on the model. (default: true)
# allow_dynamic_fields: true
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false
# User Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
sessions:
default:
database: healthy_grocery_test
hosts:
- localhost:27017
options:
consistency: :strong
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
options:
skip_version_check: true
safe: true