Search code examples
ruby-on-railscredentials

MASTER KEY NOT GENERATED RAILS 6


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?


Solution

  • 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.