dynamic drop down list

D

Dan Thomas

Hello,

I'm trying to make a drop down list from an array. For now, just hard
coding, later will use an actual array. This is in an erb file.

The first problem is that I can't find documentation on "select". Is it
a function, a class? (I'm new to Ruby). Can you point me to the
documentation?

The second problem is that according to some forums, the following
should work, but it doesn't, and I can't figure out the error message.


<%= select("borrowers", "borrower_id", [ ["name1", "value1"],["name2",
"value2"],["name3", "value3"]]) %>

ERROR: wrong argument type String (expected Array)

I have tried everything. Thanks!
 
M

Marcello Henrique

Hello,

I'm trying to make a drop down list from an array. =A0For now, just hard
coding, later will use an actual array. This is in an erb file.

The first problem is that I can't find documentation on "select". =A0Is i= t
a function, a class? =A0(I'm new to Ruby). =A0Can you point me to the
documentation?

The second problem is that according to some forums, the following
should work, but it doesn't, and =A0I can't figure out the error message.


<%=3D select("borrowers", "borrower_id", [ ["name1", "value1"],["name2",
"value2"],["name3", "value3"]]) %>

ERROR: =A0wrong argument type String (expected Array)

I have tried everything. Thanks!

You can do how follow:

<% menus_list =3D [["name1", "value1"], ["name2", "value2"], ["name3",
"value3"]] %>
<%=3D select("borrowers", "borrower_id", options_for_select(menus_list)) %>

Hugs.
--=20
Marcello Henrique
Blog - http://faraohh.wordpress.com
Associa=E7=E3o Software Livre de Goi=E1s (www.aslgo.org.br)
Cercomp - UFG (www.cercomp.ufg.br)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top