Skip to content

Commit

Permalink
Adding data seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jcasimir committed Jan 11, 2012
1 parent 705183c commit 03175ee
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions db/seeds.rb
Expand Up @@ -5,3 +5,15 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)

tags = (0..10).collect{ Fabricate(:tag) }

10.times do
article = Fabricate(:article)
article.created_at = article.created_at - (rand(300) + 100).hours
article.tags = tags.sort_by{ rand }[0..rand(tags.length)]
article.save
(rand(10)).times do
Fabricate(:comment, :article => article, :created_at => article.created_at + rand(100).hours)
end
end

0 comments on commit 03175ee

Please sign in to comment.