1 class MerchandisePurchase < Purchase
2 belongs_to :merchandise
5 validates_presence_of :merchandise_id
6 validates_presence_of :quantity
8 validates_numericality_of :merchandise_id
9 validates_numericality_of :quantity
13 errors.add(:merchandise_id, "does not exist in the database") if merchandise.nil?
14 #errors.add(:quantity, "must be 1 or greater") if quantity < 1