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 6721633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:21:09+00:00 2026-05-26T09:21:09+00:00

I am a beginning developer, and I was able to successfully use this tutorial

  • 0

I am a beginning developer, and I was able to successfully use this tutorial (I’m in Rails 3): http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic/ to allow for users to reset their passwords, however I also have a customer model that I need to do this for, and I’m running into issues (listed below code). I think the error is my routing, but I’m not sure how to fix it.

routes.rb

resources :password_resets do
  get 'edit_customer'
  post 'edit_customer'
end

password_resets_controller.rb

class PasswordResetsController < ApplicationController
before_filter :load_user_using_perishable_token, :only => [:edit, :update]
before_filter :load_customer_using_perishable_token, :only => [:edit_customer, :update_customer]
before_filter :require_no_user, :require_no_customer

def new
render
end

def create
@user = User.find_by_email(params[:email])
@customer = Customer.find_by_email(params[:email])
if @user
  @user.deliver_password_reset_instructions!
  flash[:notice] = "Instructions to reset your password have been emailed to you. " +
    "Please check your email."
  redirect_to new_user_session_path
elsif
  if @customer
  @customer.deliver_customer_password_reset_instructions!
  flash[:notice] = "Instructions to reset your password have been emailed to you. " +
    "Please check your email."
  redirect_to new_customer_session_path
  end
else
  flash[:notice] = "No account was found with that email address"
  render :action => :new
end
end

def edit
render
end

def edit_customer
#redirect_to edit_customer_password_resets_path
end

def update
@user.password = params[:user][:password]
@user.password_confirmation = params[:user][:password_confirmation]
if @user.save
  flash[:notice] = "Password successfully updated"
  redirect_to new_user_session_path
else
  render :action => :edit
end
end

def update_customer
@customer.password = params[:customer][:password]
@customer.password_confirmation = params[:customer][:password_confirmation]
if @customer.save
  flash[:notice] = "Password successfully updated"
  redirect_to new_customer_session_path
else
  render :action => :edit
end
end

private
def load_user_using_perishable_token
  @user = User.find_using_perishable_token(params[:id])
  unless @user
    flash[:notice] = "We're sorry, but we could not locate your account." +
      "If you are having issues try copying and pasting the URL " +
      "from your email into your browser or restarting the " +
      "reset password process."
    redirect_to new_user_session_path
  end
end

def load_customer_using_perishable_token
  @customer = Customer.find_using_perishable_token(params[:id])
  unless @customer
    flash[:notice] = "We're sorry, but we could not locate your account." +
      "If you are having issues try copying and pasting the URL " +
      "from your email into your browser or restarting the " +
      "reset password process."
    #redirect_to new_customer_session_path
  end
end
end

MODELS
user.rb model

def deliver_password_reset_instructions!
reset_perishable_token!
UserMailer.password_reset_instructions(self).deliver
end

customer.rb model

def deliver_customer_password_reset_instructions!
 reset_perishable_token!
 UserMailer.customer_password_reset_instructions(self).deliver
end

VIEWS
password_resets/new

<% form_tag password_resets_path do %>
<p>Email:</p>
<%= text_field_tag "email" %><br />
<br />
<%= submit_tag "Reset my password" %>
<% end %>

password_resets/edit

<% form_for @user, :url => password_reset_path, :method => :put do |f| %>
<%= f.label :password %><br />
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Change my password and log me in"%>
<% end %>

password_resets/edit_customer

<% form_for @customer, :url => password_reset_path, :method => :put do |f| %>
<%= f.label :password %><br />
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Change my password and log me in" %>
<% end %>

It works perfectly for the code that does not have “customer” appended to it. The token generates, and I can get the email to send with the same format for the url: /password_resets//edit_customer

However, it receives an error when I try to pull up the url. With the code above, I receive this error: “No route matches {:action=>”show”, :controller=>”password_resets”}” – I can also see that it interprets the :id to be the id of the controller (which is different than how the user one works – it correctly interprets the id as the token.

I have experimented a lot:

  • change :id in controller for edit_customer in load_customer_using_perishable_token to perishable_token, customer.perishable_token, @customer.perishable_token)
  • tried to append these to “get ‘edit_customer'” using the path helper (=> “cust_pass”) – :path, :path_name, :as so i could change the url to cust_pass_path
  • i even tried to add this to the routes just to see if it would work
    match ‘/password_resets/:id/edit_customer’ => ‘password_resets#edit_customer’

So I stumped. Any help would be greatly appreciated!

  • 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-05-26T09:21:10+00:00Added an answer on May 26, 2026 at 9:21 am

    I was able to fix this by updating the url in edit_customer.rb

    from

    :url => password_reset_path
    

    to

    :url => {:action=>"update_customer", :controller=>"password_resets"}
    

    I also had to update my route.rb

    from

    resources :password_resets do
     get 'edit_customer'
     post 'edit_customer'
    end
    

    to

    resources :password_resets, :except => [:index, :destroy, :show] do
      get 'edit_customer'
      put 'update_customer'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm beginning to use ENVI+IDL (most of this relates to IDL, I think, in
I'm a beginning web developer sitting on an ambitious web application project. So after
Many beginning programmers write code like this: sub copy_file ($$) { my $from =
Since beginning to use VB.NET some years ago I have become slowly familiar with
Hello I am a beginning android developer using windows and the eclipse IDE to
I'm a beginning developer who has done a bit of audio work. I was
As a mostly front-end developer, this is in the realm of computer science that
Afternoon Developers, I have a problem that's beginning to get on my wick. I
When beginning a new web project, i'm always a bit worried about removing pieces
I'm just beginning to have a look at Objective-C and Cocoa with a view

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.