Skip to content

Instantly share code, notes, and snippets.

@elight
Created March 22, 2010 03:18
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 elight/339771 to your computer and use it in GitHub Desktop.
Save elight/339771 to your computer and use it in GitHub Desktop.
TOPPING_NAMES = %w[ketchup mustard mayonnaise pickles onions lettuce tomato]
burger = Product.create(:name => "Burger")
toppings = burger.option_types.create(:name => "toppings", :presentation => "Toppings")
all_toppings = TOPPING_NAMES.inject([]) do |all, topping|
all << toppings.option_values.create(:name => topping, :presentation => topping.upcase)
all
end
whopper = burger.variants.create(:name => "Whopper")
all_toppings.each { |t| whopper.option_values << t }
whopper.save!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment