# Newbie: Wierd ID not routing by default problem

**URL:** <https://www.ruby-forum.com/t/newbie-wierd-id-not-routing-by-default-problem/138756>\
**Category:** Rails\
**Created:** [May 27, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/newbie-wierd-id-not-routing-by-default-problem/138756 "2008-05-27T14:04:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oshuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/ea5d25/32.png) [@oshuma](https://www.ruby-forum.com/u/oshuma)\
**Post date:** [May 27, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/newbie-wierd-id-not-routing-by-default-problem/138756/1 "2008-05-27T14:04:29Z")

</div>

Ok so I was having this problem before and thought Id start again from  
scratch.

Here is an example of my index.html.erb file

\<% for user in @users %\>

 \<%= h user.SurName %\> \<%= h user.ForeName %\>

```
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?',

```

:method =\> :delete %\>

 \<% end %\>

\<%= link\_to ‘New user’, new\_user\_path %\>

The links rendered for show edit and destroy are all wrong they  
basically leave out the ID of the user and so don’t work as links

EG: “Show” links to /users/ rather than say /users/10 for example, and  
“Edit” links to /users//edit rather than /users/10/edit

I find if I edit my code to be more of the form

```
<td><%= link_to 'Show', :action => 'show', :id => user.ID %></td>
<td><%= link_to 'Edit', edit_user_path(user.ID) %></td>

```

Then the paths are fine, but every tutorial I’ve read seems to imply  
that this shouldn’t be necessary. Am I doing something obvious wrong?

My routes.rb file is very standard

ActionController::Routing::Routes.draw do |map|  
map.resources :users

map.root :controller =\> “users”

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

---

<div class="post-metadata">

**Author:** ![oshuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/ea5d25/32.png) [@oshuma](https://www.ruby-forum.com/u/oshuma)\
**Post date:** [May 27, 2008, 2:23pm UTC](https://www.ruby-forum.com/t/newbie-wierd-id-not-routing-by-default-problem/138756/2 "2008-05-27T14:23:57Z")

</div>

this should work:

\<%= link\_to 'Show', user\_path(user.id) %\> \<%= link\_to 'Edit', edit\_user\_path(user.id) %\> \<%= link\_to 'Destroy', user\_path(user.id), :confirm =\> 'Are you sure?', :method =\> :delete %\>

---

<div class="post-metadata">

**Author:** ![oshuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/ea5d25/32.png) [@oshuma](https://www.ruby-forum.com/u/oshuma)\
**Post date:** [May 27, 2008, 2:28pm UTC](https://www.ruby-forum.com/t/newbie-wierd-id-not-routing-by-default-problem/138756/3 "2008-05-27T14:28:02Z")

</div>

Thorsten M. wrote:

> this should work:
> 
> \<%= link\_to 'Show', user\_path(user.id) %\> \<%= link\_to 'Edit', edit\_user\_path(user.id) %\> \<%= link\_to 'Destroy', user\_path(user.id), :confirm =\> 'Are you sure?', :method =\> :delete %\>
> 
> Ok cool, but does this mean that I’ve just been reading bad tutorials?  
> Or is it a configuration issue?
