Azren
Azren

Reputation: 237

Edit Multiple (reference Railscasts Episode #165)

I'm following Railscasts Episode #165 Edit Multiple but having issue where when I go to the product index page it is not showing my list of products. I'm getting only the header and the link to new product. Any idea what I did wrong?

By the way I'm using rails 3.2.3

Thank you.

routes.rb

resources :products do
  collection do
    post :edit_multiple
    put :update_multiple
  end
end

resources :categories

index.html.erb

<h1>Listing products</h1>

<% form_tag edit_multiple_products_path do %>
<table>
  <tr>
    <th></th>
    <th>Name</th>
    <th>Category</th>
    <th>Price</th>
  </tr>
<% for product in @products %>
  <tr>
    <td><%= check_box_tag "product_ids[]", product.id %></td>
    <td><%= product.name %></td>
    <td><%= product.category.name %></td>
    <td><%= product.price %></td>
    <td><%= link_to "Edit", edit_product_path(product) %></td>
    <td><%= link_to "Destroy", product, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
<%= submit_tag "Edit Checked" %>
<% end %>

<p><%= link_to "New Product", new_product_path %></p>

Upvotes: 0

Views: 145

Answers (2)

urjit on rails
urjit on rails

Reputation: 1893

I think this is typo. you forgot to use "=" You should do <%= form_tag edit_multiple_products_path do %>

Upvotes: 1

Jordan Running
Jordan Running

Reputation: 106027

You need <%= form_tag ... instead of <% form_tag .... Without the = the return value (i.e. your form) is discarded rather than added to the output.

Upvotes: 1

Related Questions