Add Bitem (bought items) MVC
[cs356-p2-videostore.git] / app / models / bitem.rb
1 class Bitem < ActiveRecord::Base
2   belongs_to :customer
3   belongs_to :merchandise
4
5   validates_presence_of :date
6   validates_presence_of :customer_id
7   validates_presence_of :merchandise_id
8   validates_numericality_of :customer_id
9   validates_numericality_of :merchandise_id
10   validates_associated :customer
11   validates_associated :merchandise
12
13   protected
14   def validate
15     errors.add(:customer_id, "does not exist is the database") if customer.nil?
16     errors.add(:merchandise_id, "does not exist in the database") if merchandise.nil?
17   end
18 end