Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 email password in environment.rb? Push to git safe?

I am certain that I should not publish my email password to the public git repository in the environment.rb file. Is there a way to avoid this without including the entire file in the .gitignore?

like image 340
chris Avatar asked Jan 19 '23 15:01

chris


1 Answers

You could save your email credentials within another file config/email.credentials.yml:

host: ...
username: ...
password: ...
...

and within your environment.rb file just load them with (for example):

YAML.load_file("#{Rails.root}/config/email.credentials.yml")['username']

then you would mention the credentials file within the .gitignore file.

Additionally, if you deploy the app on several servers, you might check that the file exists within an initializer and otherwise raise an error. So you make sure the app doesn't start unless the mail config file is present.

like image 68
moritz Avatar answered Jan 31 '23 09:01

moritz