我的 Rails 应用程序有问题;它没有认识到应该存在的路线。我在routes.rbresources :inquiries
文件的顶部包含了,以确保我的查询模型有基本的 CRUD 操作,该模型旨在为我的网站分类用户反馈。当我尝试呈现查询索引的视图时,我在浏览器中收到以下错误:
`No route matches {:action=>"show", :controller=>"inquiries"}`
控制台中的一个简单$ rake routes
说明表明这是不正确的:`
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"}`
我应该提到的是我的/inquiries/路由加载失败,而不是单个显示页面。index.html.erb文件如下:
'<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>`
关于为什么应用程序找不到路线的任何想法?在此先感谢您的时间。