module Logistics module Core class Agency < ApplicationRecord validates :code, :name, presence: true, allow_blank: false validates :code, :uniqueness => { :scope => [:name, :agency_category_id] } validates :name, :uniqueness => { :scope => [:code, :agency_category_id] } validates :telephone, :contact_telephone, length: { maximum: 13 } belongs_to :agency_category delegate(:name, to: :agency_category, prefix: true) end end end