Sha256: e88147b290e9145878179db013f8cfbd16883704ffa211c40bec4887598e5b0d

Contents?: true

Size: 703 Bytes

Versions: 44

Compression:

Stored size: 703 Bytes

Contents

module Workarea
  class Inquiry
    include ApplicationDocument

    field :name, type: String
    field :email, type: String
    field :order_id, type: String
    field :subject, type: String
    field :message, type: String

    validates :subject, length: { maximum: 1_000 }
    validates :message, presence: true,
                        length: { maximum: 2_000 }

    validate :subject_exists

    def full_subject
      Workarea.config.inquiry_subjects[subject]
    end

    private

    def subject_exists
      unless subject.blank? ||
        Workarea.config.inquiry_subjects.keys.include?(subject)
        errors.add(:subject, I18n.t('errors.messages.inclusion'))
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
workarea-core-3.5.16 app/models/workarea/inquiry.rb
workarea-core-3.4.37 app/models/workarea/inquiry.rb
workarea-core-3.5.15 app/models/workarea/inquiry.rb
workarea-core-3.4.36 app/models/workarea/inquiry.rb
workarea-core-3.5.14 app/models/workarea/inquiry.rb
workarea-core-3.4.35 app/models/workarea/inquiry.rb
workarea-core-3.5.13 app/models/workarea/inquiry.rb
workarea-core-3.4.34 app/models/workarea/inquiry.rb
workarea-core-3.5.12 app/models/workarea/inquiry.rb
workarea-core-3.4.33 app/models/workarea/inquiry.rb
workarea-core-3.5.11 app/models/workarea/inquiry.rb
workarea-core-3.5.10 app/models/workarea/inquiry.rb
workarea-core-3.4.32 app/models/workarea/inquiry.rb
workarea-core-3.5.9 app/models/workarea/inquiry.rb
workarea-core-3.4.31 app/models/workarea/inquiry.rb
workarea-core-3.5.8 app/models/workarea/inquiry.rb
workarea-core-3.4.30 app/models/workarea/inquiry.rb
workarea-core-3.5.7 app/models/workarea/inquiry.rb
workarea-core-3.4.29 app/models/workarea/inquiry.rb
workarea-core-3.5.6 app/models/workarea/inquiry.rb