How can I pass config from Rails 4.1 secrets.yml file to mongoid.yml assuming I have the scenario below:
config/secrets.yml file
default: &mongodb
mongodb_host: <%= ENV['TRG_MONGODB_HOST'] %>
mongodb_host_port: <%= ENV['TRG_MONGODB_HOST_PORT'] %>
mongodb_database: <%= ENV['TRG_MONGODB_DATABASE'] %>
mongodb_db_username: <%= ENV['TRG_MONGODB_DB_USER'] %>
mongodb_db_passowrd: <%= ENV['TRG_MONGODB_DB_PASSWORD'] %>
development:
secret_key_base: xxxxxxxxyyyy
<<: *mongodb
Shortened config/mongoid.yml file
development:
# Configure available database sessions. (required)
sessions:
default:
uri: mongodb://username:password@champ.mongohq.com:17856/ffff
# uri: mongodb://Rails.application.secrets.mongodb_db_username:Rails.application.secrets.mongodb_db_password@Rails.application.secrets.mongodb_host:Rails.application.secrets.mongodb_host_port/Rails.application.secrets.mongodb_database
# uri: mongodb://ENV['mongodb_db_username']:ENV['mongodb_db_password']@ENV['mongodb_host']:ENV['mongodb_host_port']/ENV['mongodb_database']
The only way the mongoid.yml works is when I directly add the database settings using uri: mongodb://username:password@champ.mongohq.com:17856/ffff. If I use uri: mongodb//Rails.application.secrets.xx the settings are not picked up. Also, the settings are not picked up when I use uri: mongodb://ENV['mongodb_db_username'].
I also tried passing the environment variables directly to mongoid.yml using embedded ruby like this uri:mongodb://<%= ENV['TRG_MONGODB_DB_USER'] %> but it also did not work.
Any suggestions on how to make Rails4.1 secrets.yml file to pass settings to mongoid.yml file.