Skip to content

Instantly share code, notes, and snippets.

@hzmangel
Created April 19, 2013 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hzmangel/5421035 to your computer and use it in GitHub Desktop.
Save hzmangel/5421035 to your computer and use it in GitHub Desktop.
Select tag used in rails
# Rails code
# @foo = [1,2,3,4]
= select_tag "foo", options_for_select(@foo), :prompt => "Please select a foo"
# @bar is an collection of objects, each of which has key_method key and value_method val
= select_tag "bar", options_from_collection_for_select(@bar), :prompt => "Please select a bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment