463cfd339a34d5086baecc9200b61ca3d0f6746a
[cs356-p2-videostore.git] / app / models / merchandise.rb
1 class Merchandise < ActiveRecord::Base
2   validates_presence_of :name
3   validates_numericality_of :quantity
4   validates_numericality_of :price
5
6   protected
7   def validate
8     errors.add(:quantity, "cannot be negative") if quantity < 0
9     errors.add(:price, "cannot be negative") if price < 0
10     errors.add(:price, "cannot be less than $0.01") if price < 0.01
11   end
12 end