1 class Bitem < ActiveRecord::Base
3 belongs_to :merchandise
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
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?