title: Accessing a user in forgot password method in rails
body: <p>I'm having a problem in accessing the email of the user in forgotpassword method.  How can I access the email without creating a new user in this method. I have send_new_password method in users.rb model.</p>
  
  <pre><code>def forgot_password
      if request.post?
        user = User.find_by_email(params[:user][:email])
        puts user
        if user and user.send_new_password
          flash[:message]  = "A new password has been sent by email."
         # redirect_to root_path
        else
          flash[:warning]  = "Couldn't send password"
        end
      end
    end
  </code></pre>
  
  <p>Here is my forgot password page </p>
  
  <pre><code>&lt;h1&gt;Forgot Password&lt;/h1&gt;
  &lt;%= form_for(@user) do |f| %&gt;
    &lt;%= render 'shared/error_messages', :object =&gt; f.object %&gt;
      &lt;div class="field"&gt;
      &lt;%= f.label :email %&gt;&lt;br /&gt;
      &lt;%= f.text_field :email %&gt;
    &lt;/div&gt;
  &lt;div class="actions"&gt;
      &lt;%= f.submit "Submit" %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>