Files
grecia/db/dev_seeds/debates.rb
2019-03-25 14:58:54 +01:00

28 lines
1.1 KiB
Ruby

section "Creating Debates" do
tags = Faker::Lorem.words(25)
30.times do
author = User.all.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
Debate.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
created_at: rand((Time.current - 1.week)..Time.current),
description: description,
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
terms_of_service: "1")
end
tags = ActsAsTaggableOn::Tag.where(kind: "category")
30.times do
author = User.all.sample
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
Debate.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
created_at: rand((Time.current - 1.week)..Time.current),
description: description,
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
terms_of_service: "1")
end
end