From a65b62550be2cab1214be5ea55a9ba856f778725 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Fri, 23 May 2014 21:14:06 +0000 Subject: [PATCH] sample-data: replace rand with sample --- script/sample-articles | 6 +++--- script/sample-products | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/script/sample-articles b/script/sample-articles index d9bba96..bc242b2 100755 --- a/script/sample-articles +++ b/script/sample-articles @@ -18,11 +18,11 @@ for subject in SUBJECTS article = TinyMceArticle.new( :name => name, :body => name, - :tag_list => [TAGS.rand, TAGS.rand], + :tag_list => [TAGS.sample, TAGS.sample], :profile => profile ) save article do - article.add_category categories.rand + article.add_category categories.sample end end end @@ -37,7 +37,7 @@ for subject in SUBJECTS save Gallery.new( :name => name, :body => name, - :tag_list => [TAGS.rand, TAGS.rand], + :tag_list => [TAGS.sample, TAGS.sample], :profile => profile ) end diff --git a/script/sample-products b/script/sample-products index b3a8e1b..a9c31c2 100755 --- a/script/sample-products +++ b/script/sample-products @@ -12,13 +12,14 @@ for thing in THINGS for color in COLORS name = [color, thing].join(' ') rand(10).times do |i| - profile = enterprises.rand - next if profile.products.where(:name => name).first - save Product.new( - :name => name, - :profile_id => profile.id, :price => (i * 13.7), - :product_category_id => categories.sample.id - ) + profile = enterprises.sample + next if profile.products.where(:name => name).first + product = Product.new + product.name = name + product.profile_id = profile.id + product.price = (i * 13.7) + product.product_category_id = categories.sample.id + save product end end end -- libgit2 0.21.2