Fix dev seeds rake, creating Poll Question Answers

This commit is contained in:
Bertocq
2017-10-06 12:16:59 +02:00
parent 0e7431e9e6
commit 00bb6874db

View File

@@ -557,10 +557,14 @@ print "Creating Poll Questions"
author = User.reorder("RANDOM()").first author = User.reorder("RANDOM()").first
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>" description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
open_at = rand(2.months.ago..2.months.from_now) open_at = rand(2.months.ago..2.months.from_now)
answers = Faker::Lorem.words((2..4).to_a.sample).map { |answer| answer.capitalize }
question = Poll::Question.create!(author: author, question = Poll::Question.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60), title: Faker::Lorem.sentence(3).truncate(60),
valid_answers: Faker::Lorem.words((2..7).to_a.sample).join(', '), valid_answers: answers.join(', '),
poll: poll) poll: poll)
answers.each do |answer|
Poll::Question::Answer.create!(question: question, title: answer, description: Faker::ChuckNorris.fact)
end
end end
puts "" puts ""