Skip to content

Instantly share code, notes, and snippets.

@petros
Created June 17, 2009 09:37
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 petros/131167 to your computer and use it in GitHub Desktop.
Save petros/131167 to your computer and use it in GitHub Desktop.
Rails drop down lists
if params[:category] != nil
@category = params[:category]
if @store == "[Uncategorized]"
#Get all uncategorized products
else
category = Category.find(@category)
#Get the products from that category
end
end
<%= select_tag('category', options_for_select(["[Uncategorized]"], @category) + options_from_collection_for_select(Category.find(:all), "id", "description", @category.to_i)) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment