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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:57:05+00:00 2026-05-22T19:57:05+00:00

For my current routing, the following ruby on rails code: <%= link_to current_user.name, users_path(current_user)

  • 0

For my current routing, the following ruby on rails code:

<%= link_to current_user.name, users_path(current_user) %>

which produces a link like the following:

<a href="/users.1">name</a>

In turn, Ruby on Rails has a hard time understanding this as it expects the 1 to be the format:

ActiveRecord::RecordNotFound in UsersController#show 
  Couldn't find User without an ID

Request
  Parameters: 
  {"format"=>"1"}

Which doesn’t exactly make sense for Rails to route it like that, since it much rather should be /users/1. Trying this by hand, however, gives the following result:

Routing Error
  No route matches "/users/1"

Having the ID entered per hand with an ?id= param, such as /users?id=1, works fine.

The issue is, I don’t understand where the users.id comes from, nor how to fix – my routing file looks like

routes::Application.routes.draw do
  get "register" => "users#new", :as => "register"
  get "login" => "sessions#new", :as => "login"
  post "login" => "sessions#create", :as => "do_login"
  get "logout" => "sessions#destroy", :as => "logout"

  resource :users

  root :to => "pages#welcome"
end

All actions but the one mentioned above work fine, though I’d like to find out why. rake routes lays it out like the following:

     users POST   /users(.:format)      {:action=>"create", :controller=>"users"}
 new_users GET    /users/new(.:format)  {:action=>"new", :controller=>"users"}
edit_users GET    /users/edit(.:format) {:action=>"edit", :controller=>"users"}
           GET    /users(.:format)      {:action=>"show", :controller=>"users"}
           PUT    /users(.:format)      {:action=>"update", :controller=>"users"}
           DELETE /users(.:format)      {:action=>"destroy", :controller=>"users"}

The issue here seems to be that users#show seems to have taken the place of users#index, which would be the correct thing to do for /users. Since this is all pretty much default routing with no custom routes in terms of the issue on hand, I’m quite clueless here. Any ideas?

Edit: The users#show code is as simple as:

class UsersController < ApplicationController
  def show
    @user = User.find(params[:id])
  end
end
  • 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-22T19:57:06+00:00Added an answer on May 22, 2026 at 7:57 pm

    You probably want your route to use resources :users, not resource :users.

    Also, change your link_to to use user_path instead of users_path:

    <%= link_to current_user.name, user_path(current_user) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Ruby on Rails 3's new routing system, is it possible to change the
My current Routing rules are routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL
I have the following code in my application helper. route = ActionController::Routing::Routes.recognize_path(current_uri) controller =
I've got this link: <%= link_to Profile, user_profile_path(current_user) %> and it gives me a
Without routing, HttpContext.Current.Session is there so I know that the StateServer is working. When
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
I'm trying to get the hang of basic Rails routing. I have a model
I've got webform routing setup on my asp.net webforms 3.5sp1 project. I would like
I have the following bash script which I will use to analyze all report
Current, I've got a stored procedure that has a main goal of doing a

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.