Sha256: b2c27c6c6cf93534398394193306bde707fa7eb29638d763b7ca9c021f139556
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 Bytes
Contents
puts "Running effective_polls seeds" Effective::Poll.all.each { |poll| poll.destroy! } Effective::Ballot.delete_all def build_effective_poll poll = Effective::Poll.new( title: 'Effective Poll', start_at: (Time.zone.now + 1.day).beginning_of_day, end_at: (Time.zone.now + 1.day).end_of_day, audience: 'All Users' ) build_poll_question(poll, Effective::PollQuestion::CATEGORIES) poll.save! poll end def build_poll_question(poll, category) questions = Array(category).map.with_index do |category, index| question = poll.poll_questions.build(title: "#{category} Question ##{index+1}", category: category) if question.poll_question_option? question.poll_question_options.build(title: 'Option A') question.poll_question_options.build(title: 'Option B') question.poll_question_options.build(title: 'Option C') end end questions.length == 1 ? questions.first : questions end build_effective_poll()
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
effective_polls-0.3.0 | db/seeds.rb |