Sha256: d7b78edca3d2318136d17d062f47c47f533a21600b4049460d58022dd2d103f1

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

namespace :rails_voter do
  desc "Add sample data"
  task add_sample_data: :environment do
    RailsVoter::VotingResult.destroy_all
    RailsVoter::ElectionDetail.destroy_all
    RailsVoter::Election.destroy_all

    p "Add sample data"
    p "United States presidential election, 2016 seeds"

    bf = RailsVoter::Election.create(name: "United States presidential election, 2016")

    bfd = bf.election_details.create(name: "Hillary Clinton")
    4.times { bfd.voting_results.create }

    bfd = bf.election_details.create(name: "Donald Trump")
    3.times { bfd.voting_results.create }

    bfd = bf.election_details.create(name: "Gary Johnson")
    2.times { bfd.voting_results.create }

    bfd = bf.election_details.create(name: "Jill Stein")
    2.times { bfd.voting_results.create }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_voter-0.2.1 lib/generators/rails_voter/install/templates/sample_data.rb
rails_voter-0.2.0 lib/generators/rails_voter/install/templates/sample_data.rb