Forum: Ruby on Rails Passing a collection to a form partial

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7db3b1680807d393d40260591b4ae5e0?d=identicon&s=25 sa 125 (sa125)
on 2008-12-29 14:37
I'm trying to create an editable table by rendering a partial containing
a form.

In the index:

<table>
  <%= render :partial => 'product_edit', :collection => @products %>
</table>

In the partial:

<% form_for :product do |f| %>
 <tr>
   <td><%= f.text_field :name %></td>
   <td><%= f.select :in_stock, [['YES','true'],['NO','false']] %></td>
 </tr>
<% end %>

I'm getting an error 'undefined local variable or method `product`..'

What am I doing wrong?
9b8d00f99fe595bdc45fd30439cf9c8f?d=identicon&s=25 Franz Strebel (Guest)
on 2008-12-29 14:45
(Received via mailing list)
On Mon, Dec 29, 2008 at 2:37 PM, sa 125
<rails-mailing-list@andreas-s.net> wrote:
>
> I'm trying to create an editable table by rendering a partial containing
> a form.
>
> In the index:
>
> <table>
>  <%= render :partial => 'product_edit', :collection => @products %>
> </table>

> I'm getting an error 'undefined local variable or method `product`..'

The name of the local variable is the name of the partial, which is
product_edit
in this case.
7db3b1680807d393d40260591b4ae5e0?d=identicon&s=25 sa 125 (sa125)
on 2008-12-29 15:16
right.. thanks.
This topic is locked and can not be replied to.