Sha256: afbaf0f4775e5552fd78701f77759d0965db071092b78f844137fed1897b0c92

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

module Msip
  module Concerns
    module Models
      module Pais
        extend ActiveSupport::Concern

        include Msip::Basica
        included do
          self.table_name = 'msip_pais'
          has_many :departamento, foreign_key: "id_pais", validate: true,
            class_name: 'Msip::Departamento' 
          has_one :personanacionalde, foreign_key: "nacionalde", 
            validate: true, class_name: "Msip::Persona"
          has_one :personapais, foreign_key: "id_pais", 
            class_name: "Msip::Persona"
          has_many :ubicacion, foreign_key: "id_pais", validate: true,
            class_name: 'Msip::Ubicacion' 

          validates :id, presence: true, uniqueness: true
          validates :nombreiso_espanol, presence: true, allow_blank: false, 
            length: { maximum: 200 }, 
            uniqueness: { case_sensitive: false, allow_blank: true}
          validates :nombre, presence: true, allow_blank: false, 
            length: { maximum: 200 },
            uniqueness: { case_sensitive: false, allow_blank: true}
          validates :alfa2, length: { maximum: 2 }, 
            uniqueness: { case_sensitive: false, allow_blank: true}
          validates :alfa3, length: { maximum: 3 },
            uniqueness: { case_sensitive: false, allow_blank: true}
          validates :div1, length: { maximum: 100 } 
          validates :div2, length: { maximum: 100 } 
          validates :div3, length: { maximum: 100 } 

          # A nombre se le quitan espacios de sobra
          def nombre=(val)
            self[:nombre] = val.squish if val
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
msip-2.2.0.alfa3 lib/msip/concerns/models/pais.rb
msip-2.2.0.alfa2 lib/msip/concerns/models/pais.rb
msip-2.2a2 lib/msip/concerns/models/pais.rb