Add Purchase system
[cs356-p2-videostore.git] / app / models / merchandise.rb
1 class Merchandise < ActiveRecord::Base
2   has_many :merchandise_purchases
3
4   validates_presence_of :name
5   validates_numericality_of :quantity
6   validates_numericality_of :price
7
8   protected
9   def validate
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
13   end
14 end