Sha256: fa37ef1cd54c90f62a395447b00c816eb429655d5877e547867f0dcef365b431
Contents?: true
Size: 784 Bytes
Versions: 5
Compression:
Stored size: 784 Bytes
Contents
class EmailAccessCard < ApplicationRecord belongs_to :user_card after_create :greetings_email after_update :greetings_email # after_destroy :check_active before_validation :normalize validates :value, presence: true, uniqueness: true, format: {with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i}, :allow_blank => false validates :value, :length => {:minimum => 6, :message => 'шорты'} def check_active self.user_card.set_active_card end def normalize self.value.downcase! unless self.value.nil? end def greetings_email unless self.value.blank? if saved_change_to_attribute?(:value) user = self.user_card.userable "#{user.class.name}Mailer".constantize.greetings_email(user).deliver_now end end end end
Version data entries
5 entries across 5 versions & 1 rubygems