Validate uniqueness of user email address

* Make user.email attribute unique
* Render validations error messages in users/new view
This commit is contained in:
Thibault Jouan
2011-09-08 15:40:30 +00:00
parent 35b081ed68
commit 688a178376
6 changed files with 44 additions and 1 deletions

View File

@@ -8,7 +8,10 @@ class User < ActiveRecord::Base
has_many :playlists
validates_presence_of :email, :password_hash
validates :email,
:presence => true,
:uniqueness => true
validates_presence_of :password_hash
validates_confirmation_of :password
def password=(plain_password)