model - rails application undefined method for class -
i rewrote create function in scaffold review after making associated concert model. when try submit form create review though error saying
undefined method `reviews' #class:0xab9972c>
def create @review = concert.reviews.create(review_params) end
my concert model looks
class concert < activerecord::base validates_presence_of :artist validates_presence_of :venue validates_presence_of :date has_many :reviews end
and review model looks this
class review < activerecord::base validates_presence_of :artist validates_presence_of :venue validates_presence_of :date belongs_to :user belongs_to :concert end
i added relations within migration files still error. can explain me causing , how go creating review belongs concert?
the association has_many :reviews
instance method. suspect in create method want this:
def create @concert = concert.new @concert.save @review = @concert.reviews.create(review_params) end
Comments
Post a Comment