# Wrong number of arguments (0 for 1)

**URL:** <https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893>\
**Category:** Rails\
**Created:** [January 13, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893 "2008-01-13T13:46:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 13, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893/1 "2008-01-13T13:46:39Z")

</div>

Hi,  
I got this error i got after i click the link to go to the product page  
where if it is the first time i enter this page, i will be able to save  
and when i enter the page the subsequent times i will be able to edit  
the data i had just save. Anyone please help. What went wrong here?

The error i got is:

ArgumentError in Create\_setup\_profile#find\_count  
Showing app/views/create\_setup\_profile/\_update\_prod\_desc.rhtml where  
line #14 raised:

wrong number of arguments (0 for 1)

Extracted source (around line #14):

11:

  
12:   
13: PRODUCT  
NAME  
14: \<%= form.text\_field :product\_name  
%\>  
15:   
16:   
17: SIZE

Trace of template inclusion:  
/app/views/create\_setup\_profile/find\_count.rhtml

RAILS\_ROOT: ./script/…/config/…

In my controller:

def find\_count  
session[:count] ||= 0  
session[:count] += 1  
end

In the find\_count.rhtml:

\<% if session[:count] == 1 %\>  
\<% form\_for :e0\_1\_prod\_desc, :url =\> { :action =\> :save\_prod\_desc },  
:html =\> { :id =\> “product” } do |form| %\>

\<%= render :partial =\> ‘prod\_desc’ %\>

| | 

\<%= link\_to\_function 'Next', "$('product').submit()" -%\>

```
  <%= button_to 'update', :controller => "create_setup_profile",
                  :action => "update_prod_desc" %>
  </div>
  </td>
    </tr>
  </tbody>
</table>

```

 \<% end %\>

\<% elsif session[:count] \> 1 %\>  
\<% form\_for :e0\_1\_prod\_desc, :url =\> { :action =\> :edit\_prod\_desc },  
:html =\> { :id =\> “update\_product” } do |form| %\>

```
<%= render :partial => 'update_prod_desc' %>

```

| | 

```
  <p><%= link_to_function 'Next', "$('update_product').submit()"

```

-%\>

```
  </div>
  </td>
    </tr>
  </tbody>
</table>

```

 \<% end %\> \<% end %\>

Thanks  
user splash

 |

 |

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 13, 2008, 2:09pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893/2 "2008-01-13T14:09:17Z")

</div>

On 13 Jan 2008, at 12:46, fries 88 wrote:

> Hi,  
> I got this error i got after i click the link to go to the product  
> page  
> where if it is the first time i enter this page, i will be able to  
> save  
> and when i enter the page the subsequent times i will be able to edit  
> the data i had just save. Anyone please help. What went wrong here?

You need to be passing the form builder through to the partial  
(via :locals for example).  
Since you haven’t, ruby assumes that form refers to the method form,  
which does indeed take at least one argument.

Fred

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 13, 2008, 2:28pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893/3 "2008-01-13T14:28:21Z")

</div>

Frederick C. wrote:

> On 13 Jan 2008, at 12:46, fries 88 wrote:
> 
> > Hi,  
> > I got this error i got after i click the link to go to the product  
> > page  
> > where if it is the first time i enter this page, i will be able to  
> > save  
> > and when i enter the page the subsequent times i will be able to edit  
> > the data i had just save. Anyone please help. What went wrong here?
> 
> You need to be passing the form builder through to the partial  
> (via :locals for example).  
> Since you haven’t, ruby assumes that form refers to the method form,  
> which does indeed take at least one argument.
> 
> Fred

Hi,  
I don’t quite understand the previous posting. Can anyone please  
elaborate.

Thanks  
user splash

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 13, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893/4 "2008-01-13T17:05:50Z")

</div>

On 13 Jan 2008, at 13:28, fries 88 wrote:

> > > and when i enter the page the subsequent times i will be able to
> 
> Hi,  
> I don’t quite understand the previous posting. Can anyone please  
> elaborate.

You’re trying to use your formbuilder ‘form’ in your partial, but  
there is no local variable called form in that partial and so ruby  
assumes you’re calling the form function, which requires at least one  
parameter (hence the error). You need to pass the form to the partial  
using locals, ie render :partial =\> ‘some\_partial’, :locals =\> {:form  
=\> foo}  
will make a local variable in that partial called form and whose value  
is foo.

Fred

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 13, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1/125893/5 "2008-01-13T17:11:07Z")

</div>

Or, name the partial ‘\_form.html.erb’ and render it as an object:

\<%= render :partial =\> ‘form’, :object =\> form %\>

On Jan 13, 10:04 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
