Ruby on rails 在轨道上找到工作路线有困难
我的Ruby on rails 在轨道上找到工作路线有困难,ruby-on-rails,routes,ruby-on-rails-3.2,Ruby On Rails,Routes,Ruby On Rails 3.2,我的路线中有以下内容。rb: resources :resources match "/resources/:category" => 'resources#index', :as => :resources 在我的index.html.erb中,我有以下内容:L <% @categories.each do |category| %> <li class="active"> <%= link_to category.name, resou
路线中有以下内容。rb
:
resources :resources
match "/resources/:category" => 'resources#index', :as => :resources
在我的index.html.erb中,我有以下内容:L
<% @categories.each do |category| %>
<li class="active">
<%= link_to category.name, resour_path(:category=>category.name.parameterize), :class => "large", remote => true %>
</li>
<% end %>
category.name.parameterize),:class=>large,remote=>true%>
我想提交到ResourcesController
的index操作,因为我想在页面上显示不同的项目,就像在filter中一样
链接当前在调用show操作而不是index操作时出错
我如何让他们提交到routes controller的索引操作?当前往路线时,永远不会到达行match”/resources/:category“
。路径/resources/some category
与resources:resources
匹配,并且some category
被视为显示
操作的id
选择1
切换行,以便首先匹配匹配
行
match "/resources/:category" => 'resources#index', :as => :resources
resources :resources
选择2
转向
进入
工具书类
如中所述:
Rails路由是按照指定的顺序匹配的,因此,如果在get“photos/poll”上方有一个resources:photos,那么资源行的show操作的路由将在get行之前匹配。要解决此问题,请将get行移到resources行上方,以便首先匹配它
match "/resources/:category" => 'resources#index', :as => :resources
resources :resources
请发布错误以及
rake routes
的相关输出。我将使用选项1。谢谢
resources :resources, :except => :show