Sha256: c86efddb743cd16d176c51cd04ab406ab188f7e8d4a539b057d3a1add66f664e
Contents?: true
Size: 703 Bytes
Versions: 3
Compression:
Stored size: 703 Bytes
Contents
require 'peoplefinder' class Peoplefinder::Token < ActiveRecord::Base self.table_name = 'tokens' after_initialize :generate_value validate :valid_email_address def to_param value end def valid_email_address if !Peoplefinder::EmailAddress.new(user_email).valid_format? errors.add(:base, I18n.t('peoplefinder.errors.tokens.invalid_address')) elsif !Peoplefinder::EmailAddress.new(user_email).valid_domain? errors.add(:base, I18n.t('peoplefinder.errors.tokens.invalid_domain')) end end def self.for_person(person) Peoplefinder::Token.create!(user_email: person.email) end private def generate_value self.value ||= SecureRandom.uuid end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
peoplefinder-0.1.1 | app/models/peoplefinder/token.rb |
peoplefinder-0.1.0 | app/models/peoplefinder/token.rb |
peoplefinder-0.0.2 | app/models/peoplefinder/token.rb |