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
28 lines
1.2 KiB
Ruby
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
|