Forum: Ruby on Rails Change Password with acts_as_authenticated

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eecd295cdec2454c66e2015036a39408?d=identicon&s=25 scott (Guest)
on 2006-01-13 22:52
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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2006-01-13 22:58
(Received via mailing list)
On 1/13/06, scott <scottnj@gmail.com> 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/...
http://collaboa.techno-weenie.net/repository/file/...
http://collaboa.techno-weenie.net/repository/file/...
http://collaboa.techno-weenie.net/repository/file/...

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


--
rick
http://techno-weenie.net
Eecd295cdec2454c66e2015036a39408?d=identicon&s=25 scott (Guest)
on 2006-01-13 23:30
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 Olson wrote:
> On 1/13/06, scott <scottnj@gmail.com> 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/...
> 
http://collaboa.techno-weenie.net/repository/file/...
> 
http://collaboa.techno-weenie.net/repository/file/...
> http://collaboa.techno-weenie.net/repository/file/...
>
> If save isn't working, check for any validation errors or before_save
> callbacks that return false.
>
>
> --
> rick
> http://techno-weenie.net
This topic is locked and can not be replied to.