Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add before_validation email downcase filter

  • Loading branch information...
commit 8b519cc175b24cab4c529c1ff19c631dea4e703c 1 parent bbe22eb
@mhartl mhartl authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 app/models/user.rb
View
4 app/models/user.rb
@@ -9,11 +9,13 @@ class User < ActiveRecord::Base
dependent: :destroy
has_many :followers, through: :reverse_relationships, source: :follower
+ before_validation { |user| user.email = email.downcase }
before_save :create_remember_token
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
- validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }
+ validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
+ uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6 }
validates :password_confirmation, presence: true
Please sign in to comment.
Something went wrong with that request. Please try again.