导轨中的布线无法正常工作



在我的产品视图中,我创建了一个页面显示.html.erb,当我从/product页面单击showall链接时,我需要在此处显示我的所有产品。

下面是我的代码

routes.rb
get "/products/display" => "products#index"
 resources :products 

产品/索引.html.erb

<table>
    <% @products.each do |product| %>
        <tr class="<%= cycle('list_line_odd', 'list_line_even') %>">

          <td>
            <%= image_tag(product.image_url, :class => 'list_image') %>
          </td>
          <td class="list_description">
            <dl>
              <dt><%= product.title %></dt>
              <dd><%= truncate(strip_tags(product.description),
                               :length => 80 ) %></dd>
            </dl>
          </td>
          <td class="list_actions">
            <%= link_to 'Show1', products_display_path(product) %><br />
            <%= link_to 'Edit', edit_product_path(product) %> <br />
            <%= link_to 'Destroy', product,
                        :confirm => 'Are you sure?',
                        :method => :delete %>
          </td>
        </tr>
    <% end %>
  </table>

产品展示.html.erb

此页面将包含与产品/索引.html.erb 页面相同的内容,但编辑、显示和销毁选项除外

根据 Rails Routes 文档 (2.10.2)

#routes.rb
resources :products do 
   collection do 
     get "display", :to => "products#index"
   end
end

最新更新