简体   繁体   English

在application.rb中存储银行帐户详细信息

[英]Storing bank account details in application.rb

I have a Rails app that is utilizing Stripe for payment processing. 我有一个利用Stripe进行支付处理的Rails应用程序。 I need to create a scheduled cron job that once a day performs two transfers. 我需要创建一个每天执行两次传输的预定cron作业。

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. 我正在考虑将它们放在服务器或application.rb文件中的环境变量中。 It'd be easier to put in application.rb, but I'm open to suggestion. 将它放入application.rb会更容易,但我愿意接受建议。

Thanks! 谢谢!

I think this kind of data is confidential, so I would keep them outside of the VCS. 我认为这种数据是保密的,所以我会将它们保留在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. 它不会驻留在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

Rails 4.1 introduced a new file for storing such type of information at config/secrets.yml . Rails 4.1在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). 如果您正在使用或计划升级到Rails 4.1(本着约定优于配置的精神),我建议使用这个。

You can retrieve these within Rails as such: 你可以在Rails中检索这些:

Rails.application.secrets.bank_account.number

and so on. 等等。 Make sure to tell your VCS to ignore this file. 确保告诉您的VCS忽略此文件。 You can find more information regarding secrets.yml in the official release notes . 您可以在官方发行说明中找到有关secrets.yml的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM