Sha256: 0a22cdbf2692d47b78837df3ac65313252f305d3623e82d0c2a4150afe2fc3a9

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 KB

Contents

module Phcmemberspro
  class Member::Listing < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

		# Paper Trail Initialize
    has_paper_trail :class_name => 'Phcmemberspro::ListingVersions'

    # Relationships
    belongs_to :profile, class_name: 'Phcmemberspro::Member::Profile'
    has_and_belongs_to_many :categories, class_name: 'Phcmemberspro::Directory::Category', :join_table => 'categories_listings'

    # Form Fields Validation
    validates :listing_company_name,
      presence: true

    validates :listing_contact_name,
      presence: true

    validates :listing_address_line_1,
      presence: true

    validates :listing_city,
      presence: true

    validates :listing_country,
      presence: true

    validates :listing_province,
      presence: true

    validates :listing_postal_code,
      presence: true

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

    validates :listing_website,
      presence: true,
      format: { with: URI::regexp(%w(http https)), message: "Please follow this URL format http or https://www.**********.com" }

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

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

    def phc_nice_url_slug
      [
        [:listing_company_name, :listing_contact_name]
      ]
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
phcmemberspro-92.0.3 app/models/phcmemberspro/member/listing.rb
phcmemberspro-92.0.2 app/models/phcmemberspro/member/listing.rb
phcmemberspro-92.0.1 app/models/phcmemberspro/member/listing.rb
phcmemberspro-92.0.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-91.4.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-91.3.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-91.2.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-91.1.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-91.0.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-90.0.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-89.0.0 app/models/phcmemberspro/member/listing.rb
phcmemberspro-88.0.0 app/models/phcmemberspro/member/listing.rb