Given the following code from the book ruby on rails tutorial (rails 5)
class User < ApplicationRecord
has_many :microposts
end
class Micropost < ApplicationRecord
belongs_to :user
validates :content, length: { maximum: 140 }
end
After executing actions in the console, I have such an error.
Traceback (most recent call last): ActiveRecord::StatementInvalid (SQLite3::SQLException: no such column: microposts.user_id: SELECT "microposts".* FROM "microposts" WHERE "microposts"."user_id" = ? LIMIT ?)
Can someone please help me clarify what the problem is?
has_many :micropost
tohas_many :microposts
inside your User model – Vishal Taj PM