app/models/user.rb in as_user-0.0.2 vs app/models/user.rb in as_user-0.0.3

- old
+ new

@@ -1,5 +1,17 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string(255) not null +# name :string(100) +# password_digest :string(60) +# created_at :datetime not null +# updated_at :datetime not null +# + class User < ActiveRecord::Base self.table_name = "users" attr_accessible :email, :name, :password, :password_confirmation has_secure_password @@ -8,8 +20,9 @@ validates :name, presence: true, length: {maximum: 49} 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: 3} - validates :password_confirmation, presence: true + validates :password, :password_confirmation, presence: true, length: {minimum: 3}, if: Proc.new { |user| + user.new_record? or user.password + } end