Validate uniqueness of user email address
* Make user.email attribute unique * Render validations error messages in users/new view
This commit is contained in:
@@ -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)
|
||||
|
@@ -1,4 +1,8 @@
|
||||
= form_for(@user, :url => users_path) do |f|
|
||||
- if @user.errors.any?
|
||||
%ul
|
||||
- @user.errors.full_messages.each do |m|
|
||||
%li= m
|
||||
%table
|
||||
%tbody
|
||||
%tr
|
||||
|
Reference in New Issue
Block a user