Files
openfoodnetwork/app/models/customer.rb
2015-04-16 10:59:15 +10:00

11 lines
333 B
Ruby

class Customer < ActiveRecord::Base
belongs_to :enterprise
belongs_to :user, :class_name => Spree.user_class
validates :code, presence: true, uniqueness: {scope: :enterprise_id}
validates :email, presence: true
validates :enterprise_id, presence: true
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
end