Home>
I want to solve

Even if you deploy an application developed with Rails to Heroku, the following screen will appear. As soon as I seeded it on Heroku, I couldn't open it.
When I checked the error on heroku logs, it was as follows.

ActionView :: Template :: Error (Couldn't find Result with'id' = 2):
Completed 500 Internal Server Error in 141ms

Looking at the error, the routing was the problem.

ActionController :: RoutingError (No route matches [GET] "/ results"):
What I checked

No route matches [GET] "/ posts" error resolution example
https://qiita.com/KONTA2019/items/b75f940399506dfe8430

Verification work and results

When I checked the routing description, it was normal.

routes.rb

Rails.application.routes.draw do
  root to:'results # index'
  get'results /: id', to:'results # win_or_lose'
end

The index action in the results controller should show a view of index.html.erb, but I don't know why.

I tried resetting the database in an attempt to withdraw the seed.

heroku run rake db: migrate: reset

However, a sentence that seems to be an error came out.

Running rails db: migrate on ⬢ sugar-league ... up, run.3929 (Free)
DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use ʻActiveSupport :: LoggerSilence` instead (called from<main>at /app/config/application.rb: 7)

I migrated again.

heroku run rake db: migrate
Running rake db: migrate on ⬢ sugar-league ... up, run.4699 (Free)
DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use ʻActiveSupport :: LoggerSilence` instead (called from<top (required)>at /app/config/application.rb: 7)

After all, it has not been migrated properly. I would like to know the possible causes and remedies.

  • Answer # 1

    Heroku had ids added every 10th.
    With reference to the following, I operated the DB from Sequel Pro and completed it.
    https://t.co/OdM9gplcV2

    The lack of id = 2 was a hint.