# Wrong number of arguments (0 for 1) in \[\]

**URL:** <https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1-in/171474>\
**Category:** Rails\
**Created:** [July 3, 2009, 6:34am UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1-in/171474 "2009-07-03T06:34:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 3, 2009, 6:34am UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1-in/171474/1 "2009-07-03T06:34:39Z")

</div>

I am creating a multiple-selection list box with :

\<% form\_\_list1 = [] %\>  
\<%= select\_tag, options\_for\_select([“A”,“B”,“C”,“D”], selected =“A”),  
html\_options = {“size” =\> 5, “multiple” =\> true}) %\>

I get  
wrong number of arguments (0 for 1)  
alluding to form\_\_list1[] . How else should I specify this to not have  
this error? -Janna B

---

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 3, 2009, 9:39am UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1-in/171474/2 "2009-07-03T09:39:47Z")

</div>

2009/7/3 JannaB [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> this error? -Janna B  
> I don’t know what form\_\_list1 is for but you have missed the first  
> parameter for select\_tag. Also when you have an error it is worth  
> giving more information on the error reported. When putting code in  
> an email it is best to copy and paste it if possible so as to  
> eliminate typos in the mail, and to ensure that the code shown is  
> exactly as in the app. You may have done this of course.

Colin

---

<div class="post-metadata">

**Author:** ![mistressjanna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mistressjanna](https://www.ruby-forum.com/u/mistressjanna)\
**Post date:** [July 3, 2009, 11:29pm UTC](https://www.ruby-forum.com/t/wrong-number-of-arguments-0-for-1-in/171474/3 "2009-07-03T23:29:19Z")

</div>

On Jul 3, 12:33 am, JannaB [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am creating a multiple-selection list box with :
> 
> \<% form\_\_list1 = [] %\>  
> \<%= select\_tag, options\_for\_select([“A”,“B”,“C”,“D”], selected =“A”),  
> html\_options = {“size” =\> 5, “multiple” =\> true}) %\>

I’m not sure what the error that you’re getting is, but there are  
enough in this fragment to go around.

- select\_tag shouldn’t be followed by a comma; written that way, you  
are calling it without arguments.

- select\_tag requires the first argument to be the name of the field

- the final argument to options\_for\_select is positionial; the  
"selected = " part is not required (nor is it meaningful). Similarly  
for html\_options. The only thing that both statements will accomplish  
is setting local variables to the various array values.

- keys in the options array are traditionally symbols; not really a  
bug, but a slightly incorrect idiom.

–Matt J.
