Contact - Registrar relation

This commit is contained in:
Andres Keskküla 2014-10-07 16:14:36 +03:00
parent 9519538744
commit 3d652bf85b
11 changed files with 90 additions and 16 deletions

View file

@ -13,12 +13,14 @@ class Contact < ActiveRecord::Base
has_many :domain_contacts
has_many :domains, through: :domain_contacts
# TODO remove the x_by
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
belongs_to :registrar
accepts_nested_attributes_for :address, :disclosure
validates :code, :phone, :email, :ident, :address, presence: true
validates :code, :phone, :email, :ident, :address, :registrar,presence: true
validate :ident_must_be_valid
#validate :presence_of_one_address
@ -33,6 +35,8 @@ class Contact < ActiveRecord::Base
delegate :street, to: :address#, prefix: true
delegate :zip, to: :address#, prefix: true
#scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
has_paper_trail class_name: 'ContactVersion'

View file

@ -4,6 +4,7 @@ class Registrar < ActiveRecord::Base
has_many :ns_sets
has_many :epp_users
has_many :users
has_many :contacts
validates :name, :reg_no, :address, :country, presence: true
validates :name, :reg_no, uniqueness: true