Sha256: 098b972c1aea305bc2a994745cee74666e432a2b53ad859cefd385e1acd1bc28
Contents?: true
Size: 899 Bytes
Versions: 13
Compression:
Stored size: 899 Bytes
Contents
module EgovUtils class Person < ApplicationRecord # This is kept for accepts_nested_attributes_for compatibility, but # overloaded below. has_one :residence, class_name: 'EgovUtils::Address' has_many :addresses has_one :natural_person, dependent: :destroy has_one :legal_person, dependent: :destroy enum person_type: { natural: 1, legal: 16 } validates :person_entity, presence: true accepts_nested_attributes_for :residence, :natural_person, :legal_person delegate :fullname, :fullname=, to: :person_entity def person_entity case person_type when 'natural' natural_person when 'legal' legal_person end end def residence addresses.order(created_at: :desc).first end def residence=(address) addresses << address end def to_s person_entity.to_s end end end
Version data entries
13 entries across 13 versions & 1 rubygems