Sha256: 507b131afe39095417ffeec2a3f329a9607c8d6b4424ed38f98f5416eee2bc3b

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Phcmembers
  class Member::Address < ApplicationRecord

		# Clean URL Initialize
		extend FriendlyId

		# Add Paper Trail
		has_paper_trail :class_name => 'Phcmembers::AddressVersions'

		# Model Relationships
    belongs_to :profile, class_name: 'Phcmembers::Member::Profile'

    # Validation for Form Fields
    validates :mcaddressl1,
      presence: true,
      length: { minimum: 2 }

    validates :mccity,
      length: { minimum: 3 }

    validates :mcprovince,
      presence: true,
      length: { minimum: 2 }

    validates :mccountry,
      presence: true,
      length: { minimum: 2 }

    validates :mcpostalcode,
      presence: true,
      length: { minimum: 3 }

    validates :mctype,
      presence: true,
      length: { minimum: 2 }

    # Clean URL Define
		friendly_id :phcmembers_address_slug, use: [:slugged, :finders]

		# Define for Multiple Records
		def phcmembers_address_slug
			[
				[:mcaddressl1, :mccity, :mcprovince]
			]
		end

    def country_name
      country = ISO3166::Country[country_code]
      country.translations[I18n.locale.to_s] || country.mccountry
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phcmembers-61.5.0 app/models/phcmembers/member/address.rb
phcmembers-61.4.0 app/models/phcmembers/member/address.rb
phcmembers-61.3.0 app/models/phcmembers/member/address.rb