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.4.28 app/models/workarea/inquiry.rb
workarea-core-3.5.5 app/models/workarea/inquiry.rb
workarea-core-3.4.27 app/models/workarea/inquiry.rb
workarea-core-3.5.4 app/models/workarea/inquiry.rb
workarea-core-3.4.26 app/models/workarea/inquiry.rb
workarea-core-3.5.3 app/models/workarea/inquiry.rb
workarea-core-3.4.25 app/models/workarea/inquiry.rb
workarea-core-3.5.2 app/models/workarea/inquiry.rb
workarea-core-3.4.24 app/models/workarea/inquiry.rb
workarea-core-3.5.1 app/models/workarea/inquiry.rb
workarea-core-3.4.23 app/models/workarea/inquiry.rb
workarea-core-3.4.22 app/models/workarea/inquiry.rb
workarea-core-3.5.0 app/models/workarea/inquiry.rb
workarea-core-3.4.21 app/models/workarea/inquiry.rb
workarea-core-3.5.0.beta.1 app/models/workarea/inquiry.rb
workarea-core-3.4.20 app/models/workarea/inquiry.rb
workarea-core-3.4.19 app/models/workarea/inquiry.rb
workarea-core-3.4.18 app/models/workarea/inquiry.rb
workarea-core-3.4.17 app/models/workarea/inquiry.rb
workarea-core-3.4.16 app/models/workarea/inquiry.rb