Additional implementation in application in development environment (implementation of comment function)
Push to Heroku where you deploy
Error when trying to post a comment on the Heroku app
macOS Catalina 10.15.6
ruby 2.6.5
Rails 6.0.3.4
MySQL : 5.6.47
When you operate the app on Heroku, you can check the log by typing the command in the terminal.
terminal
% heroku logs --tail --app app name
# --tail is an option to display the last 10 lines
Here is an excerpt of the error part after execution.
Next, we will deepen the error part.
The reason for the error is written in the image above.
Completed 500 Internal Server Error
ActiveRecord::StatementInvalid (Mysql2::Error: Table 'heroku_***.comments' doesn't exist):
1 indicates that the error is a server-side error. This '500' is called "HTTP status code" and expresses the meaning of the response in HTTP communication. To introduce some ...
--200: Normal response
--302: Perform redirect
--404: Request to a non-existent URL
2 is a hint to solve this error.
--ActiveRecord :: StatementInvalid: Error when using Active Record
--Table'*** .comments' doesn't exist: comments The table does not exist
The comment feature worked fine in the development environment, and I got an error when trying to post a comment on Heroku. And looking at this error statement, the following are possible causes of the error:
I haven't created a comment table on Heroku </ b>.
Let's actually solve it.
Run the following command in the terminal:
terminal
(Control +After exiting the log screen with C)
% heroku run rails db:migrate
This successfully resolved the error!
--Checked the log in the terminal to handle the error on Heroku
--Check the error statement and identify the cause
--Created a table with heroku run rails db: migrate
--The error was successfully resolved
If an error occurs, I'm not a little impatient. Especially, errors in the production environment are especially scary.
I'm worried if it can be solved, but it's always important to keep calm and organize the situation. And take appropriate measures.
We will increase the experience points and accumulate so that we can become an error handling craftsman!
Recommended Posts