[Ruby on Rails] credential does not work in production environment even though I saved production.key

Task

Note that the credential that was running locally did not work in the production environment deployed on Capistrano and was stuck for about 30 minutes.

Local console output


irb(main):002:0> Rails.application.credentials.slack
=> {:token=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}

Production console output


irb(main):002:0> Rails.application.credentials.slack
=> nil

Conclusion

The cause is that the following commands for operating credentials were executed only on dev.

Change local credentials


$  EDITOR="vi" bin/rails credentials:edit 

This alone doesn't change config/credentials/production.yml.enc, so There is no point in reflecting config/credentials/production.key.

As shown below, change the actual credential and push to solve it.

Production Credential change


$  EDITOR="vi" bin/rails credentials:edit -e production

It's not a big deal if you know it, but I forgot about it because of the prejudice that the locals operate only for dev. It was an embarrassing jam that revealed that I didn't really understand how credentials work.

Recommended Posts

[Ruby on Rails] credential does not work in production environment even though I saved production.key
[Ruby on Rails] When parameter id acquisition does not work
Hivernate Validator does not work in WAS Liberty environment
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
Where I was interested in Progate's Ruby on Rails course [params]
Build a development environment where Ruby on Rails breakpoints work on Windows
I summarized the flow until implementing simple_calendar in Ruby on Rails.
Ruby on Rails Japanese-English support i18n
Ruby on Rails 6.0 environment construction memo
Pay.JP Solution when it can be done locally but it does not work well in the production environment
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
[Rails] About the error that the image is not displayed in the production environment
[Ruby on Rails] Search function (not selected)
Ruby on Rails in Visual Studio Codespaces
JavaScript (vanilla) does not respond in Rails.
Image is not displayed in production environment
Beginners create portfolio in Ruby on Rails
[Rails] Reset the database in the production environment
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
I stumbled while learning Rails on Cloud9 ~ Oops VFS connection does not exist ~
[Ruby On Rails] Error in test using RSpec MySQL client is not connected
rails tutorial About account activation in production environment
Recommendation of Service class in Ruby on Rails
Rails5.1 + puma SSL connection in local production environment
Rails new in Ruby on Rails ~ Memorandum until deployment 2
[Personal memo] Ruby on Rails environment construction (Windows)
500 Internal Server Error occurs in Rails production environment
Rails new in Ruby on Rails ~ Memorandum until deployment 1
[Ruby on Rails] Let's build an environment on mac
(Ruby on Rails6) Creating data in a table
Ruby on Rails development environment construction on M1 Mac
[Ruby on Rails] How to install Bootstrap in Rails
@BeforeStep does not work in Tasklet of spring-batch
I made a portfolio with Ruby On Rails
If hash [: a] [: b] [: c] = 0 in Ruby, I want you to extend it recursively even if the key does not exist.