Harald
> I have a big Problem by changing the Password of user.
You didn''t say what your proble is!
Anyway, here is - working - code I use to reset the user''s lost
password.
in the users_controller.rb
------------------------------
def generate_and_send_new_password
..
@user = User.find_by_login(params[:login])
@user.password_confirmation = @user.password = generate_password
flash[:notice] = "new password sent to #{@user.email}"
PasswordMailer.deliver_new_password( @user, @user.password,
login_url+"?login=#{@user.login}")
render :action => ''password_changed''
end
# src:
http://www.rubyonrailsblog.com/articles/2006/09/29/ruby-on-rails-random-password-generator
def generate_password(length = 6)
chars = (''a''..''z'').to_a +
(''A''..''Z'').to_a +
(''1''..''9'').to_a -
[''o'', ''O'', ''i'',
''I'']
Array.new(length) { chars[rand(chars.size)] }.join
end
end
HTH
Alain Ravet
--------
http://blog.ravet.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---