Add a few listings to the seeds file (#2761)
This commit is contained in:
parent
8ebfb74796
commit
2e55b9d82f
1 changed files with 19 additions and 0 deletions
19
db/seeds.rb
19
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue