-
-
Save alexdunae/6dd6599f2ff4f3fd58b5 to your computer and use it in GitHub Desktop.
IMG 240: Crowdfunder seeds.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crowdfunder seed data | |
puts 'Deleting any existing data...' | |
[Pledge, FundingLevel, Project].each { |model| model.destroy_all } | |
puts 'Adding data...' | |
nanny = Project.create( | |
name: 'Robot Nanny', | |
description: "This robot nanny will care for your kids, your pets and even you!\n\nRequires very little maintenance.\n\nPledge and help us build the future!") | |
nanny.funding_levels.create(reward_name: 'Robot Nanny - Purple', amount: 100) | |
nanny.funding_levels.create(reward_name: 'Robot Nanny - Pink', amount: 120) | |
nanny.funding_levels.create(reward_name: 'Robot Nanny - Collector’s Edition', amount: 250) | |
jetpack = Project.create( | |
name: 'Personal Jetpack', | |
description: "After four years of messing around in our basements, we're finally ready to start production on our Personal Jetback 3000.\n\nOur goal is to raise $100,000,000 to build our factory, get government approval and patent our technology.") | |
jetpack.funding_levels.create(reward_name: 'T-shirt', amount: 10) | |
jetpack.funding_levels.create(reward_name: 'T-shirt plus Coffee Table Book', amount: 100) | |
jetpack.funding_levels.create(reward_name: 'Personal Jetpack plus Helmet', amount: 1000) | |
names = ['Christina', 'Elder', 'Evelyn', 'Henrique', 'Jéssica', 'Kerene', 'Lucas', 'Lucas', 'Maria', 'Melissa', 'Mike', 'Raphael', 'Ronaldo', 'Steve', 'Thiago', 'Vance'] | |
funding_level_ids = FundingLevel.pluck(:id) | |
names.each do |name| | |
Pledge.create( | |
name: name, | |
email: "#{name.downcase}@example.com", | |
funding_level_id: funding_level_ids.sample) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment