Rails 2.3.11
I’m trying to add a drop-down “sort by” switch to a page. The page determines how to sort the items in the list by a URL argument (http://…/places?sort=name). How would I have a drop-down menu that, when changed, goes to the appropriate page?
"Name" -> ?sort=name
"Category" -> ?sort=cat
"Abbreviation" -> ?sort=abbrev
"Building Number" -> ?sort=num
Those ^ are the mappings. I’m also not sure how to have the drop-down menu say one thing, but submit another.
Thank you!
Basically you build the options out first by passing an Array of 2 element arrays where the first element is your display value, and the second element is the select value. options_for_select will generate all the options for you, which you can then pass to select_tag.