问题
I have an app that uses authlogic for login mechanism.
My sign up page requires no password confirmation but password reset page does.
acts_as_authentic do |a|
a.require_password_confirmation = true
end
The above code turns on password confirmation for all the actions but which is not required in my case. It should be turned on when password reset is called and off when user signs up.
Is there a way to turn this on and off on a conditional basis ?
Thanks
回答1:
Set password confirmation to false.
acts_as_authentic do |a|
a.require_password_confirmation = false
end
Set the password_confirmation
value in the create
action of UsersController
.
before_action :set_password_confirmation, :only => :create
def set_password_confirmation
if params[:user]
params[:user][:password_confirmation] = params[:user][:password]
end
end
来源:https://stackoverflow.com/questions/24675303/authlogic-turn-off-require-password-confirmation-for-a-certain-case