Sha256: 345e583e004b654046be7bdb24879b58f08a17798f6aac3a3d82f9f625bed034
Contents?: true
Size: 1.09 KB
Versions: 14
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Spotlight ## # Exhibit feedback contacts class ContactEmail < ActiveRecord::Base extend Devise::Models devise :confirmable belongs_to :exhibit validate :valid_email validates :exhibit, presence: true scope :confirmed, -> { where.not(confirmed_at: nil) } def to_s email end def recently_sent? confirmation_sent_at > 3.days.ago if confirmation_sent_at? end protected def valid_email begin parsed = Mail::Address.new(email) rescue Mail::Field::ParseError => e Rails.logger.debug "Failed to parse email #{email}: #{e}" end errors.add :email, 'is not valid' if parsed.nil? || parsed.address != email || parsed.local == email end def send_devise_notification(notification, *args) notice = notification_mailer.send(notification, self, *args, exhibit: exhibit) if notice.respond_to? :deliver_now notice.deliver_now else notice.deliver end end def notification_mailer Spotlight::ConfirmationMailer end end end
Version data entries
14 entries across 14 versions & 1 rubygems