public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
insoshi / app / models / email_verification.rb
100644 30 lines (25 sloc) 0.665 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# == Schema Information
# Schema version: 28
#
# Table name: email_verifications
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# code :string(255)
# created_at :datetime
# updated_at :datetime
#
 
class EmailVerification < ActiveRecord::Base
  belongs_to :person
  validates_presence_of :person_id, :code
  before_validation_on_create :make_code
  after_create :send_verification_email
  
  private
  
    # Make a unique verification code.
    def make_code
      self.code = UUID.new
    end
    
    def send_verification_email
      PersonMailer.deliver_email_verification(self)
    end
end