I have a somewhat basic question, I have my User Model with the
following attributes:
User.email
User.hashed_password
User.salt
Attr Accessors
User.password_confirmation
User.email_confirmation
class User < ActiveRecord::Base
validates_length_of :password, :within => 5…40
validates_uniqueness_of :email
validates_presence_of :email, :email_confirmation, :password,
:password_confirmation
validates_confirmation_of :password
validates_confirmation_of :email
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+.)+
[a-z]{2,})$/i, :message => “email address didn’t validate, example
[email protected]”
attr_protected :id, :salt
attr_accessor :password, :password_confirmation, :email_confirmation
end
In my users_controller, I have 2 action, change_email and
change_password.
What is the best way to update for just a password change OR email
change (different actions). The reason
I’m asking this is that whenever I try and save just password and
password_confirmation, rails returns
errors for email not being present. (it’s not on the form in
change_password action)
My problem seems to be this, all my users validators are firing even
though I’m only editting a select