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
20 lines
1.1 KiB
Ruby
20 lines
1.1 KiB
Ruby
section "Creating banners" do
|
|
Proposal.last(3).each do |proposal|
|
|
title = Faker::Lorem.sentence(word_count = 3)
|
|
description = Faker::Lorem.sentence(word_count = 12)
|
|
target_url = Rails.application.routes.url_helpers.proposal_path(proposal)
|
|
banner = Banner.create!(title: title,
|
|
description: description,
|
|
style: ["banner-style banner-style-one",
|
|
"banner-style banner-style-two",
|
|
"banner-style banner-style-three"].sample,
|
|
image: ["banner-img banner-img-one",
|
|
"banner-img banner-img-two",
|
|
"banner-img banner-img-three"].sample,
|
|
target_url: target_url,
|
|
post_started_at: rand((Time.current - 1.week)..(Time.current - 1.day)),
|
|
post_ended_at: rand((Time.current - 1.day)..(Time.current + 1.week)),
|
|
created_at: rand((Time.current - 1.week)..Time.current))
|
|
end
|
|
end
|