Check followings
seting to use credential.yml.enc with master.key in production
config/environments/production.rb
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
config.require_master_key = true
setting the credential.yml.enc
EDITOR="vim" rails credentials:edit
(you may need to install vim)
Dockerfile
## install vim
RUN apt-get update && apt-get install apt-file -y && apt-file update && apt-get install vim -y
active_storage setting
config/environments/production.rb
config.active_storage.service = :amazon
config/storage.yml
amazon:
service: S3
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
region: xxxxxxxxxxxxxxxxxx
bucket: xxxxxxxxxxxxxxxxxx
Make it sure works on Rails console(local
[1] pry(main)> Rails.application.credentials.dig(:aws, :access_key_id)
"xxxxxxxxxxxxxx"
switch the setting of the strage strategy on Development
to make sure S3 setting is right.
If it works completely, the problem must be in Heroku.
# Store uploaded files on the local file system (see config/storage.yml for options).
# config.active_storage.service = :local
config.active_storage.service = :amazon
put the value of master.key into Heroku config
heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
Top comments (2)
Oh, I'm sorry. I forgot to mention the option
-a
.If you already added your heroku git on your git remote repositories, you can omit the option -a.
I will also remove the -a option from this post to avoid making confusing.
I use Mac OS X.
cat path/to/file.key
with backquote works on bash. But I'm not sure it works on Windows.Perhaps, You'd better type the dos command instead, or use the signature directly.