Created
May 14, 2013 04:10
-
-
Save Imranshaikh/5573635 to your computer and use it in GitHub Desktop.
For invalid email in ruby on rails debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_accessible :email, :name, :password, :password_confirmation | |
has_secure_password | |
before_save{ self.email.downcase! } | |
before_save { |user| user.email = email.downcase } | |
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 }, | |
uniqueness: { case_sensitive: false } | |
validates :password, presence: true, length: { minimum: 6 } | |
validates :password_confirmation, presence: true | |
end |
Yes, bilal bhai successfully inserted.... Thanks alot :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this
validates_format_of :email, :with => /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/