Rails 6 Heroku Devise error ActiveSupport::MessageEncryptor::InvalidMessage Rails 6 Heroku Devise error ActiveSupport::MessageEncryptor::InvalidMessage heroku heroku

Rails 6 Heroku Devise error ActiveSupport::MessageEncryptor::InvalidMessage


I might be late here but keep this in mind when working with Rails 6 and credentials:

1- Whenever you edit rails credentials(eg: rails credentials:edit --environment production), rails generates a new key(config/credentials/production.key) and also lets you add your credentials in a file.

2- In production.rb file, uncomment config.require_master_key = true and set an ENV(RAILS_MASTER_KEY) in your server with the key mentioned in config/credentials/production.key(eg: heroku config:set RAILS_MASTER_KEY=XXXXXXXXX).

Rails will use RAILS_MASTER_KEY ENV, to decrypt your credentials instead of finding file inside config/credentials/production.key.

3- Never share production.key file with anyone nor push it to VC and dont attempt to change it because all of the credentials might get lost if this file gets delete/changed.


Rails 6 uses different keys for production environment credentials. Use the key from config/credentials/production.key

You'll probably need to re-add everything to the production credentials enc file too.EDITOR=vi rake credentials:edit --environment