0

I'm confused about how to properly use figaro with Rails 4.2. So in application.yml (which is checked into .gitignore), I have this:

secret_key_base: 123456

And then in secrets.yml, I have this:

development:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

The gem should be handling the ENV part of setting the credentials, according to everything I've read. Why is this not working?



EDIT 1: In application.yml I have: mandrill_user_name: [email protected] and mandrill_password: 1234567890

And in development.rb I have:

config.action_mailer.default_url_options = { :host => "localhost:3000" }

config.action_mailer.smtp_settings = {
  address: "smtp.mandrillapp.com",
  port: 587,
  domain: "localhost:3000",
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: ENV["mandrill_user_name"],
  password: ENV["mandrill_password"]
}

Shouldn't application.yml be taking care of this?

0

1 Answer 1

1

If is redundant to have the variable in the secrets.yml file and the application.yml file. I.e. use the application.yml file ONLY to declare ENV Vars.

So long as it is in the apllication.yml file you can call it throughout your rails app just like you are doing:

ENV["SECRET_KEY_BASE"]

Varialbles stored in the secrets.yml file are called via

Rails.application.secrets.SECRET_KEY_BASE
Sign up to request clarification or add additional context in comments.

10 Comments

I'm sorry, but I'm severely confused. It doesn't work, so I think I'm doing something wrong. I have secret_key_base: 123456 in application.yml, and then I call it in development.rb with ENV["secret_key_base"]. Nothing happens. Also, if it's redundant to use secrets.yml, why does this answer say otherwise?: stackoverflow.com/a/26569119/2009652
What do you mean nothing happens?
can you add your development.rb action mailer config code to your post
1) is figaro in your Gemfile? 2) did you restart spring? 3) did you restart your webserver after updating your application.yml file? –
1) spring auto loads the environment so you can perform tasks faster (bin/rake, bin/rails). 2) the file becomes relatively worthless, just leave it there the way it is generated when you create the project or you will run into error when committing to heroku 3) it's best practice not to store them in the repo 4) if this solved your problems mark the answer correct
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.