# Passing a collection to a form partial

**URL:** <https://www.ruby-forum.com/t/passing-a-collection-to-a-form-partial/156524>\
**Category:** Rails\
**Created:** [December 29, 2008, 2:37pm UTC](https://www.ruby-forum.com/t/passing-a-collection-to-a-form-partial/156524 "2008-12-29T14:37:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa125](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@sa125](https://www.ruby-forum.com/u/sa125)\
**Post date:** [December 29, 2008, 2:37pm UTC](https://www.ruby-forum.com/t/passing-a-collection-to-a-form-partial/156524/1 "2008-12-29T14:37:22Z")

</div>

I’m trying to create an editable table by rendering a partial containing  
a form.

In the index:

 \<%= render :partial =\> 'product\_edit', :collection =\> @products %\>

In the partial:

\<% form\_for :product do |f| %\>

 \<%= f.text\_field :name %\> \<%= f.select :in\_stock, [['YES','true'],['NO','false']] %\> \<% end %\>

I’m getting an error ‘undefined local variable or method `product`…’

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![sa125](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@sa125](https://www.ruby-forum.com/u/sa125)\
**Post date:** [December 29, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/passing-a-collection-to-a-form-partial/156524/2 "2008-12-29T14:45:50Z")

</div>

On Mon, Dec 29, 2008 at 2:37 PM, sa 125  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to create an editable table by rendering a partial containing  
> a form.
> 
> In the index:
> 
> \<%= render :partial =\> 'product\_edit', :collection =\> @products %\>

> 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.

---

<div class="post-metadata">

**Author:** ![sa125](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@sa125](https://www.ruby-forum.com/u/sa125)\
**Post date:** [December 29, 2008, 3:16pm UTC](https://www.ruby-forum.com/t/passing-a-collection-to-a-form-partial/156524/3 "2008-12-29T15:16:38Z")

</div>

right… thanks.
