Sha256: e2e02b8a0116f71e171a9ccb46d684088d152b0d02c2827041f484acb02fba8d

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

module RocketCMS
  module Models
    module ContactMessage
      extend ActiveSupport::Concern
      include RocketCMS::Model
      include RocketCMS.orm_specific('ContactMessage')

      included do

        apply_simple_captcha message: RocketCMS.configuration.contacts_captcha_error_message

        validates_email_format_of :email, unless: 'email.blank?'
        if RocketCMS.config.contacts_message_required
          validates_presence_of :content
        end
        validate do
          if email.blank? && phone.blank?
            errors.add(:email, I18n.t('rs.no_contact_info'))
          end
        end
        after_create do
          ContactMailer.new_message_email(self).deliver
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ack_rocket_cms-0.9.1.3 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.9.1.2 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.9.1.1 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.9.1 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.9 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.8.2 lib/rocket_cms/models/contact_message.rb
ack_rocket_cms-0.8.0 lib/rocket_cms/models/contact_message.rb