1 class Merchandise < ActiveRecord::Base
2 has_many :merchandise_purchases
4 validates_presence_of :title
5 validates_numericality_of :quantity
6 validates_numericality_of :price
10 errors.add(:quantity, "cannot be negative") if quantity < 0
11 errors.add(:price, "cannot be negative") if price < 0
12 errors.add(:price, "cannot be less than $0.01") if price < 0.01