Rails PR: rails/rails#33521
This patch makes it possible to use per-environment credentials (i.e., config/credentials/staging.yml.enc
) in Rails 5.2.
- Drop
backport_rails_six_credentials.rb
andbackport_rails_six_credentials_command.rb
somewhere, for example, into thelib/
folder - Add this line to
config/application.rb
:
# Right after `require "rails"`
require_relative "../lib/backport_rails_six_credentials"
- Add this line to
config/boot.rb
:
# Right after `require 'bundler/setup'`
require_relative "../lib/backport_rails_six_credentials_command"
Now you can call:
$ bundle exec rails credentials:edit -e staging
create config/credentials/staging.key
...
And Rails.application.credentials
now uses env-specific credentials if they're present and master/root credentials otherwise.
Ah gotcha. That makes sense. Thanks for the clarification!