Commit a65b62550be2cab1214be5ea55a9ba856f778725

Authored by Rodrigo Souto
1 parent 152a9965

sample-data: replace rand with sample

Showing 2 changed files with 11 additions and 10 deletions   Show diff stats
script/sample-articles
... ... @@ -18,11 +18,11 @@ for subject in SUBJECTS
18 18 article = TinyMceArticle.new(
19 19 :name => name,
20 20 :body => name,
21   - :tag_list => [TAGS.rand, TAGS.rand],
  21 + :tag_list => [TAGS.sample, TAGS.sample],
22 22 :profile => profile
23 23 )
24 24 save article do
25   - article.add_category categories.rand
  25 + article.add_category categories.sample
26 26 end
27 27 end
28 28 end
... ... @@ -37,7 +37,7 @@ for subject in SUBJECTS
37 37 save Gallery.new(
38 38 :name => name,
39 39 :body => name,
40   - :tag_list => [TAGS.rand, TAGS.rand],
  40 + :tag_list => [TAGS.sample, TAGS.sample],
41 41 :profile => profile
42 42 )
43 43 end
... ...
script/sample-products
... ... @@ -12,13 +12,14 @@ for thing in THINGS
12 12 for color in COLORS
13 13 name = [color, thing].join(' ')
14 14 rand(10).times do |i|
15   - profile = enterprises.rand
16   - next if profile.products.where(:name => name).first
17   - save Product.new(
18   - :name => name,
19   - :profile_id => profile.id, :price => (i * 13.7),
20   - :product_category_id => categories.sample.id
21   - )
  15 + profile = enterprises.sample
  16 + next if profile.products.where(:name => name).first
  17 + product = Product.new
  18 + product.name = name
  19 + product.profile_id = profile.id
  20 + product.price = (i * 13.7)
  21 + product.product_category_id = categories.sample.id
  22 + save product
22 23 end
23 24 end
24 25 end
... ...