LoginSignup
12
10

More than 5 years have passed since last update.

[Rails 4.x] secrets.ymlや環境変数の操作など

Last updated at Posted at 2014-11-04

Rails 4.1から追加されたconfig/secrets.ymlを使いたいと思います。
しかし、twelve factorでは環境変数の利用を薦めているようなので、両方を組み合わせようと思います。

secrets.yml

config/secrets.yml
development:
  hoge:
    key: <%= ENV["HOGE_KEY_DEV"] %>
production:
  hoge:
    key: <%= ENV["HOGE_KEY"] %>

環境変数

~/.your_shell.rc
# ENV VARIABLES
## dev
export HOGE_KEY_DEV="hogehoge"
# production
export HOGE_KEY="fugafuga"

ちなみにkeyなどを作るときに乱数を作るには

こちらをご覧下さい

12
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10