Skip to content

Instantly share code, notes, and snippets.

@jkmcrg
Last active August 29, 2015 13:56
Show Gist options
  • Save jkmcrg/9009297 to your computer and use it in GitHub Desktop.
Save jkmcrg/9009297 to your computer and use it in GitHub Desktop.
collection select
# this:
%select{name: "recipe[recipe_season_id]"}
-for season in @recipe_seasons
%option{value: season.id, selected: season_option_select(season)}= season.name
# can be replaced with this:
= f.collection_select :season_id, @recipe_seasons, :id, :name
# Where `f` is the form object, `season_id` is the field of the object that you
# want to set,`@season` is the collection, `:id` is the method to call on
# your collection to set the value of the select, and `:name` is the method
# to call to set the option text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment