Linked Questions

Popular Questions

undefined method build_list (Rails 5)

Asked by At

user.build_book does not seem to work. I get an undefined method build_book error. However,

a= user.book.build
a.save

does work. Why would that be?

rails g migration add_user_reference_to_book user:references

class Book < ApplicationRecord
  belongs_to :user
end


class User < ApplicationRecord
   has_many :books
end

Related Questions