Files
nairobi/db/dev_seeds/communities.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

23 lines
780 B
Ruby

section "Creating Communities" do
Proposal.all.each { |proposal| proposal.update(community: Community.create) }
Budget::Investment.all.each { |investment| investment.update(community: Community.create) }
end
section "Creating Communities Topics" do
Community.all.each do |community|
Topic.create(community: community, author: User.all.sample,
title: Faker::Lorem.sentence(3).truncate(60), description: Faker::Lorem.sentence)
end
end
section "Commenting Community Topics" do
30.times do
author = User.all.sample
topic = Topic.all.sample
Comment.create!(user: author,
created_at: rand(topic.created_at..Time.current),
commentable: topic,
body: Faker::Lorem.sentence)
end
end