From 2e55b9d82fe255d3dcf11a61be7a385efea4d803 Mon Sep 17 00:00:00 2001 From: rhymes Date: Wed, 8 May 2019 14:49:53 +0200 Subject: [PATCH] Add a few listings to the seeds file (#2761) --- db/seeds.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index ce07ede3a..9bdc5cfba 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -236,6 +236,25 @@ FeedbackMessage.create!( category: "spam", status: "Open", ) + +Rails.logger.info "12. Creating Classified listings" + +users = User.order(Arel.sql("RANDOM()")).to_a +users.each { |user| Credit.add_to(user, rand(100)) } + +listings_categories = ClassifiedListing.categories_available.keys +listings_categories.each_with_index do |category, index| + # rotate users if they are less than the categories + user = users.at((index + 1) % users.length) + 2.times do + ClassifiedListing.create!( + user: user, + title: Faker::Lorem.sentence, + body_markdown: Faker::Markdown.random, + category: category, + ) + end +end ############################################################################## Rails.logger.info <<-ASCII