Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在轨道上找到工作路线有困难_Ruby On Rails_Routes_Ruby On Rails 3.2 - Fatal编程技术网

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