Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- View:
- <%= title "Forgot Your Password?", :h2 %>
- <% form_for @password do |f| %>
- <%= f.error_messages %>
- <% f.field_set "Enter Your Email Address" do %>
- <%= f.text_field :email %>
- <% end %>
- <%= f.submit "Submit" %>
- <% end %>
- Controller:
- class PasswordsController < ApplicationController
- def new
- @password = Password.new
- end
- def create
- @password = Password.new(params[:password])
- @password.user = User.find_by_email(@password.email)
- if @password.save
- PasswordMailer.deliver_forgot_password(@password)
- flash[:notice] = "A link to change your password has been sent to #{@password.email}."
- redirect_to :action => :new
- else
- render :action => :new
- end
- end
- # ...
- end
- Model:
Add Comment
Please, Sign In to add comment