I am quite new to rails and I am using authlogic for my authentication system. I want to have password_confirmation when user updates his profile, but not when he is signing up.
I figured out this config option
acts_as_authentic do |c|
c.require_password_confirmation=false
end
When I do this, it ignores password_confirmation during signup (which is fine) but while editing user profile, I want it to consider password_confirmation field. is there any method I can configure this?
As you have suspended the Authlogic based validation you can achieve this with a standard Rails model validation such as:
where the
password_required?is an optional model method, which tests if you want this validation for a given scenario.UPDATE
As it seems that the
c.require_password_confirmation=falseoption means thepassword_confirmationattribute is no longer automatically created then you need to approach the solution slightly differently. Create a virtual attribute manually and a custom validation for the specific case of profile updates. Something like this: