I will write it down as a memorandum. Edit as needed.
With the following settings, the error message will be displayed in the browser in the production environment as well as in the local development environment.
config/environments/production.rb
(Omitted)
config.consider_all_requests_local = true
(Omitted)
Find the above description in the "config/environments/production.rb" file. Originally it is "false", so change it to "true".
We need to reflect this change in the production environment, so do the following two operations. ① Push to GitHub ② Execute "bundle exec cap production deploy"
When you have finished handling the error, don't forget to set it back to false and redeploy.
If Capistrano gives an error, you can't do the above. Let's check the error log directly.
Depending on the nature of the error, the logs are mainly written to the following two files. If you're not sure which one applies to you, check both.
Terminal
cat /var/www/(app name)/current/log/unicorn.stderr.log
Terminal
cat /var/www/(app name)/current/log/production.log
At first, reading the error log is a bit difficult, so here are some points. please refer.
How to check the error log of Rails app When checking the error log, be aware of the following points
How to read the error log ・ The lower the file, the newer the log. ・ Be sure to check when the log is
It is important to see when the log is for the error that occurred.
First, if there is a time stamp in the log, add 9 hours to it (the output is in standard time, so there is a time difference of 9 hours in Japan). Compare that time with the current time to check if the error has just occurred.
It may be a rare case, but if you check the log and there is no error
rm current/log/unicorn.stderr.log
After deleting the log history with ↑
less current/log/unicorn.stderr.log
It may be displayed if you confirm with ↑.
Recommended Posts