Sha256: 5577d5e1ee468d59b6c29266c9cc95f87d9d8303bf38145eb7418bb33c9ba729

Contents?: true

Size: 1.63 KB

Versions: 64

Compression:

Stored size: 1.63 KB

Contents

module Phcmembers
	class Member::Listing < ApplicationRecord

		# Clean URL Initialize
		extend FriendlyId

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

		# Model Relationships
		belongs_to :profile, class_name: 'Phcmembers::Member::Profile'
		has_many :categorylistings, class_name: 'Phcmembers::Directory::Categorylisting', dependent: :destroy
		has_many :categories, class_name: 'Phcmembers::Directory::Category', :through => :categorylistings

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

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

		validates :mbaddressl1,
			length: { minimum: 3 }

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

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

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

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

		validates :mbcontactemail,
			presence: true,
			length: { minimum: 3 },
			format: { with: /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/, message: "Please follow this Email format: *****@********.***" }

		validates :mbwebsite,
			presence: true,
			length: { minimum: 6 }

		validates :mbphone,
			presence: true,
			format: { with: /\A(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}\z/, message: "Please Follow this Phone Number Format: ***-***-****" }

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

		# Define for Multiple Records
		def phcmembers_listings_slug
			[
				[:mbcompanyname, :mbcontactname]
			]
		end

	end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
phcmembers-61.0.0 app/models/phcmembers/member/listing.rb
phcmembers-60.0.0 app/models/phcmembers/member/listing.rb
phcmembers-59.0.0 app/models/phcmembers/member/listing.rb
phcmembers-57.1.0 app/models/phcmembers/member/listing.rb
phcmembers-57.0.0 app/models/phcmembers/member/listing.rb
phcmembers-56.0.0 app/models/phcmembers/member/listing.rb
phcmembers-55.0.0 app/models/phcmembers/member/listing.rb
phcmembers-54.0.0 app/models/phcmembers/member/listing.rb
phcmembers-53.0.0 app/models/phcmembers/member/listing.rb
phcmembers-52.0.0 app/models/phcmembers/member/listing.rb
phcmembers-51.0.0 app/models/phcmembers/member/listing.rb
phcmembers-50.0.0 app/models/phcmembers/member/listing.rb
phcmembers-49.0.0 app/models/phcmembers/member/listing.rb
phcmembers-46.0.0 app/models/phcmembers/member/listing.rb
phcmembers-45.0.0 app/models/phcmembers/member/listing.rb
phcmembers-44.0.0 app/models/phcmembers/member/listing.rb
phcmembers-43.0.0 app/models/phcmembers/member/listing.rb
phcmembers-42.0.0 app/models/phcmembers/member/listing.rb
phcmembers-41.0.0 app/models/phcmembers/member/listing.rb
phcmembers-40.0.0 app/models/phcmembers/member/listing.rb