[RUBY] [Rails / Heroku] Error resolution procedure after push




Action procedure

1. Check the log in the terminal

When you operate the app on Heroku, you can check the log by typing the command in the 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.

2. Read the error

The reason for the error is written in the image above.

  1. Completed 500 Internal Server Error

  2. 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.

3. Create a table with the app on Heroku

Run the following command in the 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

[Rails / Heroku] Error resolution procedure after push
Rails Heroku deployment procedure
rails heroku error log
rails error resolution summary
Error resolution on Heroku
[Rails] Error resolution after PAYJP token generation (separate route)
Error when running git push heroku master on Heroku
[Rails] Error resolution when generating tokens with PAYJP
ITMS-90626 Error Resolution
Migration error after Activerecord association in Rails5 + Docker environment (2)
Rails uninitialized constant A simple checklist for error resolution
[Rails] About error resolution when installing devise and activeadmin
Nuxt.js x Rails app creation CORS policy Error resolution
Migration error after Activerecord association in Rails5 + Docker environment
Catch Rails Routing Error
[Rails error] unexpected tIDENTIFIER
Heroku app moving (rails)
Mac Rails Install Error
ActionController :: InvalidAuthenticityToken error resolution
[Rails] Heroku deployment flow
Rails, RSpec installation procedure
exited with code 1 error resolution with docker-compose up in rails environment
[Ruby on Rails] undefined method ╩╗id'for nil: NilClass error resolution method
[rails] heroku deployment error ActionView :: Template :: Error (Mysql2 :: Error: Table --- doesn't exist):
PG :: DatatypeMismatch error when doing heroku run rails db: migrate