Module: HasEmailAuthentication::Module::ClassMethods
- Defined in:
- lib/has_email_authentication/module.rb
Instance Method Summary collapse
-
#has_email_authentication ⇒ Object
Generates the
find_by_emailclass method.
Instance Method Details
#has_email_authentication ⇒ Object
Generates the find_by_email class method. Downcases the :email attribute before saving. Validates the presence, format and uniqueness of the :email attribute.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/has_email_authentication/module.rb', line 22 def has_email_authentication validates :email, presence: true, format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i }, uniqueness: { case_sensitive: false } before_save do self.email = email.try(:downcase) end extend(FindByEmail) end |