Question

I have a Rails app that is utilizing Stripe for payment processing. I need to create a scheduled cron job that once a day performs two transfers.

This requires me to store bank account details (routing / account number) somewhere so that I can access it and create a single use token.

I'm considering either putting them in environment variables on the server or in the application.rb file. It'd be easier to put in application.rb, but I'm open to suggestion.

Thanks!

Was it helpful?

Solution

Rails 4.1 introduced a new file for storing such type of information at config/secrets.yml. I would suggest using this one if you are on, or planning to upgrade to, Rails 4.1 (in the spirit of convention over configuration).

You can retrieve these within Rails as such:

Rails.application.secrets.bank_account.number

and so on. Make sure to tell your VCS to ignore this file. You can find more information regarding secrets.yml in the official release notes.

OTHER TIPS

I think this kind of data is confidential, so I would keep them outside of the VCS.

What seems good to me is to have an extra config eg

#config/bank.yml

development:
  account: 12345

which will not reside in the VCS.

For production all you need is a separate file that will reside in your server, where only some people can see it.

#config/bank.yml

production:
  account: 12345678
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top