Sha256: d48d0b936f483df8f41d91920110ab9be3a52c91036e52114d57534826bb8554

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

module Phcmembers
  class Member::Profile < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

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

    # Gravatar
    include Gravtastic
    gravtastic :member_email

    # Model Relationships
    has_many :addresses, class_name: 'Phcmembers::Member::Address', :dependent => :destroy
    has_many :listings, class_name: 'Phcmembers::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 :phcmembers_profiles_slug, use: [:slugged, :finders]

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phcmembers-62.1.0 app/models/phcmembers/member/profile.rb
phcmembers-62.0.0 app/models/phcmembers/member/profile.rb