Files
nairobi/db/dev_seeds/banners.rb
Javi Martín 102cf74b3d Bump faker from 1.8.7 to 2.0
Since version 2.0 introduced many breaking changes, we're upgrading to
it first.

The changes have been done by installing the rubocop-faker gem and
running:

```
rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct
```
2021-08-13 04:39:44 +02:00

23 lines
954 B
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.new(title: title,
description: description,
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))
I18n.available_locales.map do |locale|
Globalize.with_locale(locale) do
banner.description = "Description for locale #{locale}"
banner.title = "Title for locale #{locale}"
banner.save!
end
end
end
end
load Rails.root.join("db", "web_sections.rb")