简体   繁体   中英

How do I setup developer specific data in my Rails 3.2 app

We have multiple developers working on our current app. The app uses data in the cloud. The service we use has an app_id and an app_key. We have a app_id, app_key pair on this remote cloud per environment (prod, dev, test). The issue is, when each dev needs to work on his/her own feature we don't want to share the same remote app (using the app_id, app_key pair). So, each dev needs their own pair on this remote service. The keys are stored in a yaml file:

development:
  id: 4321
  key: 321

test:
  id: 12345
  key: 123

production:
  id: <%= ENV['MASTER_ID'] %>
  key: <%= ENV['MASTER_KEY'] %>

How do I set it up so that when each developer starts working on a feature he/she will already have their own keys in THEIR dev environment and they won't need to copy/paste it back into this config file every time?

(we use git if that helps)

每个开发人员在其本地开发驱动器中都应该有一个app_keys.yml ,然后将其添加到.gitignore文件中,这样git就不会对其进行跟踪。

We follow the following design for having keys/info dependent on various work machines/servers etc.:

Define a variable in environment.rb which stores the path to the directory which has all the(or single) yml file(s) which each machine needs to have.

Wherever those keys are required to be loaded, the yml file is fetched through the path set in the environment.rb file.

The advantage here is that per system only single file needs to be modified during various git processes ie the env file storing the path/to/keys/directory . Each dev/server needs to have the template of the file in that directory to replicate those files and properly place the appropriate keys in those file by themselves.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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