I added production database as the following:
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
options:
consistency: :strong
max_retries: 1
retry_interval: 0
Depend on the following docs.
And I created MONGOHQ_URL by the following command:
heroku config:add MONGOHQ_URL=mongodb://user:[email protected]:port/db_name
But when I open the console by heroku run rails c. I got the following:
There is a configuration error with the current mongoid.yml.
message:
No clients configuration provided.
summary:
Mongoid's configuration requires that you provide details about each client that can be connected to, and requires in the clients config at least 1 default client to exist.
resolution:
Double check your mongoid.yml to make sure that you have a top-level clients key with at least 1 default client configuration for it. You can regenerate a new mongoid.yml for assistance via `rails g mongoid:config`.
Example:
development:
clients:
default:
database: mongoid_dev
hosts:
- localhost:27017
Loading production environment (Rails 4.2.4)
How can I add production configuration in mongoid.yml file to deploy using heroku ?
They updated the format of the mongoid.yml file in Mongoid 5. Instead of
sessionsit needs to beclients. There are a few other changes too, I knowuserandpasswordare now nested under options unlike before. See the Mongoid docs for details.