How do I pass secret keys into mongoid.yml using secrets.yml in Rails 4.2? -
this first time using mongoid, works fine in test/local server, hitting wall when comes deploying ibm bluemix (don't ask me why bluemix, know easier if deploy heroku using figaro.)
i connecting mongolab using it's uri.
in scerets.yml:
production: secret_key_base: <%= env["secret_key_base"] %> mongo_url: "mongodb://ibmcloud_xxxxxx_xxxxxx:xxxxxx@dsxxxxxx.mongolab.com:xxxxxx/ibmcloud_xxxxxx_xxxxxx" in mongoid.yml
production: sessions: default: # standard mongodb connection uri allows easy replica set connection setup. # use environment variables or config file keep credentials safe. uri: <%= rails.application.secrets.mongo_url %>
when deploy app, staging fails because uri nil. i knew because tested hardcoding uri , works.
i not include mongoid.yml in .gitignore, though if can insert uri: <%= rails.application.secrets.mongo_url %>, should safe.
i tried hardcoding uri mongoid.yml , include in gitignore, gives me other bugs , wonder better approach.
here error message get:
2015-07-07t17:29:53.01-0400 [stg/0] out rake aborted! 2015-07-07t17:29:53.01-0400 [stg/0] out nomethoderror: undefined method `match' nil:nilclass 2015-07-07t17:29:53.01-0400 [stg/0] out /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize' 2015-07-07t17:29:53.01-0400 [stg/0] out /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/sessions/factory.rb:106:in `new' 2015-07-07t17:29:53.01-0400 [stg/0] out /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/sessions/factory.rb:106:in `parse' 2015-07-07t17:29:53.01-0400 [stg/0] out /tmp/staged/app/vendor/bundle/ruby/2.2.0/gems/mongoid-4.0.2/lib/mongoid/sessions/factory.rb:62:in `create_session' again, because uri setup in secrets.yml showing nil in mongoid.yml.
thanks in advance!!
the ruby buildpack overriding url have. need attach either mongolab or mongodb service app. buildpack auto wire in database you.
Comments
Post a Comment