Reputation: 3904
In my product view I have created a page display.html.erb and I need to show all my products here when I click showall link from the /product page.
Below are my code
routes.rb
get "/products/display" => "products#index"
resources :products
products/index.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>
products.display.html.erb
This page will contain same content as products/index.html.erb page except edit, show and destroy options
Upvotes: 0
Views: 56
Reputation: 76784
As per the Rails Routes documentation (2.10.2)
#routes.rb
resources :products do
collection do
get "display", :to => "products#index"
end
end
Upvotes: 1