Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8744799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:54:04+00:00 2026-06-13T11:54:04+00:00

Hi I’m working on a reset password action. But after click the button I

  • 0

Hi I’m working on a reset password action. But after click the button I get this error:

Called id for nil, which would mistakenly be 4 — if you really wanted the id of nil, use object_id

Here is my password_reset_controller

 class PasswordResetsController < ApplicationController

    layout "sessions"

  def new
  end

  def create
    user = User.find_by_email(params[:email])
    user.send_password_reset if user
    redirect_to root_url, :notice => "#{user.id}Las instrucciones para reestrablecer la contrasena fueron enviadas."
  end

end

and Here is my user model

class User < ActiveRecord::Base
  attr_accessible :email, :password, :password_confirmation
  has_secure_password

  before_save { |user| user.email = email.downcase }
  before_save :create_remember_token

  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
  validates :password, presence: true, length: { minimum: 6 }
  validates :password_confirmation, presence: true

    def send_password_reset
        self.password_reset_token = SecureRandom.urlsafe_base64
        self.password_reset_at = Time.zone.now
        save!
    end

  private

    def create_remember_token
        self.remember_token = SecureRandom.urlsafe_base64
    end

end

this is the view:

<% provide(:title, "Reiniciar Password") %>

<div class="row">
    <div class="span4">
        &nbsp
    </div>
    <div class="span4" id="login-box">  
        <div id="login-controls">
            <%= link_to(image_tag("logo.png"), root_path) %>
            <br>
            <br>

            <%= form_for(:password_resets, url: password_resets_path) do |f| %>
                <%= f.text_field :email, :placeholder => "Correo Electronico", :tabindex => 1, :style => "height:25px;" %>
                <%= f.button "<i class=\"icon-lock icon-white\"></i> Reiniciar Password".html_safe, :tabindex => 2,  class: "btn btn-warning", :style => "width:220px;margin-bottom:5px;" %>
            <% end %>
      </div>
    </div>
    <div class="span4">
    </div>
</div>

I don’t understan why I can’t find the user; I try to do the same at rails console and I can find the user by email, but I can generate the password_reset_token.

Please I appreciate your help.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:54:04+00:00Added an answer on June 13, 2026 at 11:54 am

    use params[:password_resets][:email]

    Please do User.all and see. check on which user record you invoked the password_reset_token method

    This means that there is no user in your database with this email.

    Use,

    user = User.find_by_email!(params[:email])
    

    method with a bang (!) will trigger an exception. find_by_email returns a nil object if the email was not found

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.