Edit Rails Credentials

To edit credentials in Rails using sublime run this, and it will open the credentials file in sublime.

Assuming we've set up credentials for each of our environements (as we've done in ZipMessage), we'll need to add the credentials to each one separately, using these commands:

Edit credentials for development:

EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" bin/rails credentials:edit --environment development

Edit credentials for test:

EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" bin/rails credentials:edit --environment test

Edit credentials for staging:

EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" bin/rails credentials:edit --environment staging

Edit credentials for production:

EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" bin/rails credentials:edit --environment production

Once saved and the file is closed, those credentials will be encrypted and saved.

You can then reference the credentials like this:

Rails.application.credentials.aws[:AWS_SITEMAP_BUCKET]

Last updated