Commit a65b62550be2cab1214be5ea55a9ba856f778725
1 parent
152a9965
Exists in
master
and in
29 other branches
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,11 +18,11 @@ for subject in SUBJECTS | ||
18 | article = TinyMceArticle.new( | 18 | article = TinyMceArticle.new( |
19 | :name => name, | 19 | :name => name, |
20 | :body => name, | 20 | :body => name, |
21 | - :tag_list => [TAGS.rand, TAGS.rand], | 21 | + :tag_list => [TAGS.sample, TAGS.sample], |
22 | :profile => profile | 22 | :profile => profile |
23 | ) | 23 | ) |
24 | save article do | 24 | save article do |
25 | - article.add_category categories.rand | 25 | + article.add_category categories.sample |
26 | end | 26 | end |
27 | end | 27 | end |
28 | end | 28 | end |
@@ -37,7 +37,7 @@ for subject in SUBJECTS | @@ -37,7 +37,7 @@ for subject in SUBJECTS | ||
37 | save Gallery.new( | 37 | save Gallery.new( |
38 | :name => name, | 38 | :name => name, |
39 | :body => name, | 39 | :body => name, |
40 | - :tag_list => [TAGS.rand, TAGS.rand], | 40 | + :tag_list => [TAGS.sample, TAGS.sample], |
41 | :profile => profile | 41 | :profile => profile |
42 | ) | 42 | ) |
43 | end | 43 | end |
script/sample-products
@@ -12,13 +12,14 @@ for thing in THINGS | @@ -12,13 +12,14 @@ for thing in THINGS | ||
12 | for color in COLORS | 12 | for color in COLORS |
13 | name = [color, thing].join(' ') | 13 | name = [color, thing].join(' ') |
14 | rand(10).times do |i| | 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 | end | 23 | end |
23 | end | 24 | end |
24 | end | 25 | end |