I'm using Ruby 1.8.7, Rails 2.3.8, and using Authlogic 2.1.6 for registration, login, logout. In fact, those three things are nearly all I've done!
During registration, if the user has errors in their registration information, I want the password and password_confirmation fields to be empty when the view is redrawn. I assumed one could clear the fields in the UsersController, as follows:
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
def create
@user = User.new(params[:user])
if @user.save
@user.save
flash[:success] = "Registration successful!"
redirect_back_or_default root_path
else
@user.password = ""
@user.password_confirmation = ""
@page_title = "Registration"
end
end
...
The password_confirmation field is successfully cleared by this code, but the password field is not. I inserted a debugger call just after the 'else', and sure enough, the value of @user.password is unchanged by the line '@user.password'. I am guessing that there is something in Authlogic that is restoring the field's value after I attempt to clear it. (I also tried setting it to 'nil', with the same result).
I've come up with a work-around, I'm explicitly setting the form field's value to "" in the view:
<%= form.password_field :password, :value => "" %>
But that doesn't seem to me the ideal way to handle it!