Skip to content

Instantly share code, notes, and snippets.

@elight
Created Mar 22, 2010
Embed
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)
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