Sha256: d45ba0f8a206fc5b70ce7f2aa26224a3f1aa1f935cd8b443541daabf36d2adc8

Contents?: true

Size: 1.66 KB

Versions: 16

Compression:

Stored size: 1.66 KB

Contents

module PhcdevworksMembers
  class Member::Listing < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Paper Trail Initialize
    has_paper_trail :class_name => "PhcdevworksMembers::MemberListingVersions"

    # Relationships
    belongs_to :profile, class_name: "PhcdevworksMembers::Member::Profile"
    has_and_belongs_to_many :categories, class_name: "PhcdevworksMembers::Directory::Category", :join_table => "phcdevworks_members_categories_lstings"

    # 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 :phcdev_members_listing_nice_urls, use: [:slugged, :finders]

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

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
phcdevworks_members-6.8.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.7.1 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.7.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.6.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.5.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.4.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.3.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.2.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.1.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-6.0.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-5.1.1 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-5.1.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-5.0.3 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-5.0.2 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-5.0.0 app/models/phcdevworks_members/member/listing.rb
phcdevworks_members-4.1.0 app/models/phcdevworks_members/member/listing.rb