I am having a problem with my Rails application; it is not recognizing a route that should exist. I’ve included resources :inquiries at the top of the routes.rb file, to ensure that there are the basic CRUD operations with my inquiries model, which is meant to catalog user-feedback for my website. When I try to render the view for the inquiry index, I get the following error in my browser:
`No route matches {:action=>"show", :controller=>"inquiries"}`
A simple $ rake routes from the console shows that this isn’t true: `
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
sessions POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
session DELETE /sessions/:id(.:format) {:action=>"destroy", :controller=>"sessions"}
inquiries GET /inquiries(.:format) {:action=>"index", :controller=>"inquiries"}
POST /inquiries(.:format) {:action=>"create", :controller=>"inquiries"}
new_inquiry GET /inquiries/new(.:format) {:action=>"new", :controller=>"inquiries"}
edit_inquiry GET /inquiries/:id/edit(.:format) {:action=>"edit", :controller=>"inquiries"}
inquiry GET /inquiries/:id(.:format) {:action=>"show", :controller=>"inquiries"}
PUT /inquiries/:id(.:format) {:action=>"update", :controller=>"inquiries"}
DELETE /inquiries/:id(.:format) {:action=>"destroy", :controller=>"inquiries"}
about /about(.:format) {:action=>"about", :controller=>"pages"}
blog /blog(.:format) {:action=>"blog", :controller=>"pages"}
techniques /techniques(.:format) {:action=>"techniques", :controller=>"pages"}
contact /contact(.:format) {:action=>"new", :controller=>"inquiries"}
reviews /reviews(.:format) {:action=>"reviews", :controller=>"pages"}
signup /signup(.:format) {:action=>"new", :controller=>"users"}
signin /signin(.:format) {:action=>"new", :controller=>"sessions"}
signout /signout(.:format) {:action=>"destroy", :controller=>"sessions"}
root /(.:format) {:action=>"home", :controller=>"pages"}`
I should mention that it is my /inquiries/ route that fails to load, and not an individual show page. The index.html.erb file is as follows:
'<h1>All Inquiries</h1>
<table>
<tr>
<th>Link</th>
<th>Name</th>
<th>Subject</th>
<th>Body</th>
</tr>
<%= @inquiries.each do |inquiry| %>
<tr>
<td><%= link_to inquiry.id, inquiry_path %></td>
<td><%= inquiry.name %></td>
<td><%= inquiry.subject %></td>
<td><%= inquiry.body[0..140] %>...</td>
</tr>
<% end %>
</table>`
Any ideas on why the application can’t find the route? Thanks in advance for your time.
I think the problem is created by the line
<td><%= link_to inquiry.id, inquiry_path %></td>By using
inquiry_path, you should appoint an inquiry to be shown. So the path should be:If you are using RESTful paths, you could simplify it to: