Sha256: c2c36fe15bd6f4ef407d05c7f4a30b0dad95cb0d548d1830d4bfa35733b0b3bd

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module Phcmemberspro
  class Member::Profile < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Add Paper Trail
    has_paper_trail :class_name => 'Phcmemberspro::ProfileVersions'

    # Gravatar
    include Gravtastic
    gravtastic :member_email

    # Model Relationships
    has_many :addresses, class_name: 'Phcmemberspro::Member::Address', :dependent => :destroy
    has_many :listings, class_name: 'Phcmemberspro::Member::Listing', :dependent => :destroy

    # Validation for Form Fields
    validates :member_firstname,
      presence: true,
      length: { minimum: 1 }

    validates :member_lastname,
      presence: true,
      length: { minimum: 1 }

    validates :member_title,
      length: { minimum: 2 }

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

    validates :member_phone,
      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 :phcmemberspro_profiles_slug, use: [:slugged, :finders]

    # Define for Multiple Records
    def phcmemberspro_profiles_slug
      [
        [:org_id, :member_firstname, :member_lastname]
      ]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcmemberspro-86.0.0 app/models/phcmemberspro/member/profile.rb