Rails error undefined method ʻimage_name'for nil: NilClass handling

Problems that occurred

Create the learned app in the same way for the output of Progate learning. Content that displays the poster and the image of the poster on the post list screen.

When I typed it according to the sample, I got an error of ʻundefined method'image_name' for nil: NilClass` But.

What I tried

-Check if there are any input errors in post.rb, views / posts / index.html.erb, related part methods, src values, etc. → No problem

Solution

As a result of google and various trials, rails db: migrate was done.

Recommended Posts

Rails error undefined method ʻimage_name'for nil: NilClass handling
[Ruby on Rails] undefined method ʻid'for nil: NilClass error resolution method
[Ruby on Rails] Follow function undefined method ʻid'for nil: NilClass error resolution
rspec Error: ActionView :: Template :: Error: undefined method `name'for nil: NilClass
About the relationship between Rails credentials.yml.enc and master.key (undefined method `[]'for nil: NilClass (NoMethodError))
RSpec error resolution undefined method `feature'for RSpec: Module
Rails console Incorrect string value error handling
rails method
[Ruby on Rails] NoMethodError undefined method `devise_for'error resolution
Rails delegate method
[Swift] Error handling
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
[Ruby] Implement error handling / iteration processing using while method
[Rails] "private method` String' called ~ "error when db: migrate
I got an error "undefined method` create'" in RSpec
[Ruby on Rails] undefined method ʻid'for nil: NilClass error resolution method
Spring Boot + PostgreSQL error resolution method
[Ruby on Rails] Follow function undefined method ʻid'for nil: NilClass error resolution
RSpec error resolution undefined method `feature'for RSpec: Module
[Ruby on Rails] NoMethodError undefined method `devise_for'error resolution