MASTER KEY NOT GENERATED RAILS 6

Viewed 1027

I have scaffolded a rails application (v6.0.3.4), after one day I realised that the master key wasn’t there. I know I can generate it, but it wouldn’t be the 'original', as I understand it.

Is it any possibility that the master key is there and I need a command to make it visible ? Is there any other solution than scaffolding again?

2 Answers

If you did not use credentials in this project before:

  1. If there is a credentials.yml file available - delete it.
  2. To generate a new credentials.yml file + a master.key, you need to run in your console:

rails credentials:edit or EDITOR=vim rails credentials:edit

  1. the credentials.yml file will be automatically added to git. the master.key will not be commited for security reasons. Save it in a separate place.
  • Delete credentials.yml.enc & master.key
  • RUN EDITOR=nano rails credentials:edit

When you commit, master.key file will not be committed to Git as it is included in .gitignore by default.

Related