Add text-only stories to fake_data task

For #414
This commit is contained in:
Chun Li 2017-11-28 10:41:58 -05:00 committed by Peter Bhat Harkins
parent 2f6c5b7e9a
commit 3bcc33b906
1 changed files with 9 additions and 2 deletions

View File

@ -15,11 +15,18 @@ class FakeDataGenerator
username: user_name
end
@stories_count.times do
@stories_count.times do |i|
user = users[Random.rand(users.length-1)]
title = Faker::Lorem.sentence(3)
tag = Tag.find_or_create_by! tag: title.split(' ').first.downcase
Story.create! user: user, title: title, url: Faker::Internet.url, tags_a: [tag.tag]
if i.even?
Story.create! user: user, title: title, url: Faker::Internet.url, tags_a: [tag.tag]
else
Story.create! user: user,
title: title,
description: Faker::Lorem.paragraphs(3).join("\n\n"),
tags_a: [tag.tag]
end
end
end
end