Files
grecia/db/dev_seeds/debates.rb
Bertocq 54e6c5fc5c Split dev_seeds into individual files for sections
Why:

Its a really huge script, and conflicts are hard to resolve on forks,
with indivudal scripts its easier to make custom changes.

How:

Following @mariacheca example using require_relative and a file under
the db/dev_seeds/ folder
2018-02-22 11:04:47 +01:00

28 lines
1.2 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 = 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 = 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