view form_tag url_for action forgot_password do What is the email addr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
view:
<% form_tag url_for(:action => 'forgot_password') do %>
What is the email address used to create your account?<br />
<%= text_field_tag :email, "", :size => 50 %><br />
<%= submit_tag 'Request Password' %>
<% end %>
controller:
def forgot_password
return unless request.post?
if @user = User.find_by_email(params[:email])
@user.forgot_password
@user.save
redirect_back_or_default(:controller => '/account', :action => 'index')
flash[:notice] = "A password reset link has been sent to your email address"
else
flash[:notice] = "Could not find a user with that email address"
end
end