Class: UserEmail

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/sum/model/user_email.rb

Instance Method Summary collapse

Instance Method Details

#activate!Object



6
7
8
9
10
11
# File 'lib/sum/model/user_email.rb', line 6

def activate!
  self.update_attribute(:active, true)
  self.user.flash = "Successfully re-activated #{self.email}."
  self.user.send_now = true
  self.user.save
end

#deactivate!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sum/model/user_email.rb', line 13

def deactivate!
  self.update_attribute(:active, false)
  begin
    $mail.deliver(
      :from => '[email protected]',
      :to => self.email,
      :subject => 'Sum deactivated',
      :body => 'Reply with the word "start" to begin receiving emails again.'
    )
    self.sent!
  rescue Exception
    self.increment!(:failures)
  end
end

#sent!Object



28
29
30
# File 'lib/sum/model/user_email.rb', line 28

def sent!
  self.update_attribute :failures, 0
end