I have the following model:
class item < ActiveRecord::Base
has_one :price
end
class price < ActiveRecord::Base
belongs_to :item
end
def
if !@item.price
@item.price.build
end
end
I get:
undefined method `build' for nil:NilClass
How would I build the price for an item if the price doesn’t exit in the prices table?
thx
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html