Add a few listings to the seeds file (#2761)

This commit is contained in:
rhymes 2019-05-08 14:49:53 +02:00 committed by Ben Halpern
parent 8ebfb74796
commit 2e55b9d82f

View file

@ -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