Skip to content

Instantly share code, notes, and snippets.

@kelhusseiny
Created April 20, 2012 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelhusseiny/2426047 to your computer and use it in GitHub Desktop.
Save kelhusseiny/2426047 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
attr_accessor :password
EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
validates :username, :presence => true, :uniqueness => true, :length => { :in => 3..20 }
validates :email, :presence => true, :uniqueness => true, :format => EMAIL_REGEX
validates :password, :confirmation => true #password_confirmation attr
validates_length_of :password, :in => 6..20, :on => :create
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment