Ruby on Rails select_tag default value
| 02-Mar-2009 | Posted by Sonia Hamilton under Ruby on Rails |
When using the Rails helper select_tag, the selected value (ie highlighted value) is a parameter to options_for_select, not select_tag. Eg:
Number of Rows: <%= select_tag(:numrows, options_for_select(%w{10 20 50 100 200 500}, session[:numrows])) %>
(much head-banging-against-wall went into working this out…)
Share This
Spam alert above! Thanks for this lil tidbit. Good to know.
Thanks Mark. Spam zapped – somehow it slipped thru…
Thanks, this helped me out!
Good tips.This really helped me. I have come across this problem twice. This is the second time i face the same problem. Why, there is not standard for the selection in rails.
Thanks for this snippet… Really helped me a lot… @ the right time too.. :)
thanks for this.. highly appreciated! :)
You’re welcome!