・ Ruby 2.5.7 ・ Rails 5.2.4.3
It is called Undefined method script_id.
However, when I look at schema.rb (before change: script_id → after change: joke_book_id), it has changed.
schema.rb
t.integer "joke_book_id"
t.integer "user_id"
t.text "introduction"
So where does this script_id come from?
After researching various things, I notice that the model is suspicious. Looking at the model, It was the same as before the change with validates: script_id, {presence: true}. Change here to a new column. validates :joke_book_id, {presence: true}
users_joke.rb
#validates :script_id, {presence: true} #Change before
validates :joke_book_id, {presence: true} #After change
It worked! !! !!
Recommended Posts