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 %> <tr> <td><%= h user.SurName %></td> <td><%= h user.ForeName %></td>
<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 %></td> </tr> <% 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