Skip to content

Instantly share code, notes, and snippets.

Created Mar 22, 2010
What would you like to do?
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)
whopper = burger.variants.create(:name => "Whopper")
all_toppings.each { |t| whopper.option_values << t }!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment