Open and edit Rails 5.2 credentials file

Public, Rails General


Created: Oct 12, 2018     Updated: Oct 12, 2018

Here is an example of how to open and edit the new credentials file that came out in Rails 5.2. This example is using Sublime as the editor.

1. From the root of the project run:

➜  EDITOR="subl --wait" rails credentials:edit

This will open up the credentials.yml file in sublime.

2. Make any edits/updates to the credentials file

For example, let's set:

secret_key: '123456789'

3. Save and close the file

This should output the following to the terminal:

New credentials encrypted and saved.

4. Accessing the key

You can access the key by calling:


This can be called anywhere in your code, as well as from the Rails console directly.