Created
March 22, 2010 03:18
-
-
Save elight/339771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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