Change Password with acts_as_authenticated

I want to have a form to change a users password. I can’t figure out
what the method in the controller should look like. I tried @user.save
and @user.update_attributes, but can’t get it to work.

My Form:
##############################
<%= start_form_tag :action => “update_password”, :id => @user.id %>
<%= password_field (“user”, “password”, :size => 20) %>
<%= password_field (“user”, “password_confirmation”, :size => 20) %>
<%= submit_tag “Change Password” %>
<%= end_form_tag %>

In My Controller:
###############################
def update_password
return unless request.post?
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = ‘User password was successfully updated.’
redirect_to :action => ‘edit’, :id => @user
else
render :action => ‘edit’, :id => @user
end
end

On 1/13/06, scott [email protected] wrote:

<%= end_form_tag %>
render :action => ‘edit’, :id => @user
end
end

Look at how I do it with Rails Weenie (which uses
acts_as_authenticated).

http://collaboa.techno-weenie.net/repository/file/rails_help/app/views/account/edit.rhtml
http://collaboa.techno-weenie.net/repository/file/rails_help/app/views/account/_form.rhtml
http://collaboa.techno-weenie.net/repository/file/rails_help/app/controllers/account_controller.rb
http://collaboa.techno-weenie.net/repository/file/rails_help/app/models/user.rb

If save isn’t working, check for any validation errors or before_save
callbacks that return false.


rick
http://techno-weenie.net

What I wrote earlier was actually working, I was testing with a password
that was too short.
When I added
<%= error_messages_for (:user) %>
it showed the error.
Thanks for the tip/reminder.

Rick O. wrote:

On 1/13/06, scott [email protected] wrote:

<%= end_form_tag %>
render :action => ‘edit’, :id => @user
end
end

Look at how I do it with Rails Weenie (which uses
acts_as_authenticated).

http://collaboa.techno-weenie.net/repository/file/rails_help/app/views/account/edit.rhtml
http://collaboa.techno-weenie.net/repository/file/rails_help/app/views/account/_form.rhtml
http://collaboa.techno-weenie.net/repository/file/rails_help/app/controllers/account_controller.rb
http://collaboa.techno-weenie.net/repository/file/rails_help/app/models/user.rb

If save isn’t working, check for any validation errors or before_save
callbacks that return false.


rick
http://techno-weenie.net