You have defined the show route as:
get "users/show"
Notice that there is no dynamic segment in this route, like :id
. That means your route is not expecting any value to be passed. BUT while linking to this route you passed @user.id
<%= link_to @post.email, users_show_path(@user.id) %>
which the route was not expecting. So, Rails assumed that you are passing the format
(like .html
, .json
, etc.) which is why you see the url formed as users/show.1
.
To fix this, I would suggest you to add a dynamic segment to your route to capture the id
of a user correctly.
Change
get "users/show"
With
get "users/show/:id" => "users#show", as: :users_show
For a user with id = 1
, when you click on the user profile link the url generated would be http://yourdomain/users/show/1