アセットコンパイル時に下記を実行するが
ターミナル(EC2)
[ec2-user@ip-172-31-23-189 <アプリ名>]$ rails assets:precompile RAILS_ENV=production
この際にエラーが表示される場合がある。
エラーが出る場合
ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["default", "development", "test", "database", "username", "password", "socket"]
下記を修正してください
database.yamlに『 <<: *default 』を追記する
(もともとあるが、いらないだろうと思い消してしまうとエラーが表示される)
config/database.yml
production:
<<: *default # ここが抜けているはず
database: <%= Rails.application.credentials.db[:database] %>
username: <%= Rails.application.credentials.db[:username] %>
password: <%= Rails.application.credentials.db[:password] %>
socket: <%= Rails.application.credentials.db[:socket] %>
追記したらpullして更新しましょう
ターミナル(EC2)
[ec2-user@ip-172-31-23-189 <アプリ名>] git pull origin master
再度
ターミナル(EC2)
[ec2-user@ip-172-31-23-189 <アプリ名>]$ rails assets:precompile RAILS_ENV=production
今度は成功するはずです