Frustrrated - Simple Drop Down

i have an array
@item = [ [name1, value1] [name2, value2] [name3, value4] ] which
comes from the controller

i want to put this into a drop down menu where the item chosen goes
to :enter_by

i also need to go back to the same form

where the same array @item is displayed but this time the item
selected ( :enter_by ) is now selected.

i don’t want to use ajax

i have read and re-read, and then made a trip to the bookstore about
select, select_tag, options_for_select
i going on 3 hours sleep in 48 hours and need this badly.

this can not be soooooo complicated.

i can get the items to display, i can return the item selected but i
can not get the selected item to show if i go back to the form.

hi rushnosh, i’m back (with a bit more time now)

i posted what you wanted (as far as i understood you) in your last
question. select which sets the selected items for a multiple select
box.
could you have a look at it and maybe tell me, what you don’t understand
or what does not fit with your request?

the only difference is, that in my example the array is hardcoded, but
you can replace it with any array you want.

ok, just typed that in:

in your controller:
@items = [[‘A’,1], [‘B’, 2], [‘C’, 3], [‘D’, 4], [‘E’, 5]]

this should’ve been returned (i simulate it):
params[:enter_by] = 2

in your view:
<%= select_tag(“enter_by”, options_for_select(@items,
params[:enter_by])) %>

where options_for_select gets two items:
the array with the options
the selected item

it should make no difference, if you render this the simple way or
replace it with ajax

i did look at your code and tested. it was not for a drop down.
i finally, finally got it to work - but i can not believe this how
ruby does it. it is extremely ugly. i know it can be done in a cleaner
fashion with ajax/rjs but i didn’t want to add another level of
difficulty to it.

the help came from this post
<http://www.falsepositives.com/index.php/2005/12/10/building-a-better-
drop-down-selection-list-for-ruby-on-rails/>

now i have to repeat this code about 100 times and i am dreading it.
almost 2 days to figure this out.

PLEASE, PLEASE let me know if there is a better way to do, there has
to be, unless folks just don’t use drop down menus/selections anymore.
until now i was so gunho about ruby.

On Apr 23, 3:38 pm, Thorsten M. <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs