Forum: Ruby on Rails wrong number of arguments (0 for 1) in []

Posted by Janna Brossard (mistressjanna)
on 2009-07-03 06:34
(Received via mailing list)
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
Posted by Colin Law (Guest)
on 2009-07-03 09:39
(Received via mailing list)
2009/7/3 JannaB <mistressjanna@hotmail.com>:
> 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
Posted by Matt Jones (Guest)
on 2009-07-03 23:29
(Received via mailing list)
On Jul 3, 12:33 am, JannaB <mistressja...@hotmail.com> 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 Jones
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.