Files
grecia/db/dev_seeds/banners.rb
Javi Martín c8270d58bd Add and apply Rails/DurationArithmetic rubocop rule
This rule was added in rubocop-rails 2.13.0. We were already applying it
most of the time.
2022-08-24 23:24:36 +02:00

23 lines
904 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((1.week.ago)..(1.day.ago)),
post_ended_at: rand((1.day.ago)..(1.week.from_now)),
created_at: rand((1.week.ago)..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")