-
-
Save xta/4004045 to your computer and use it in GitHub Desktop.
Rails Lab: Associations - seed.rake file for Songs & Artists
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
desc "Create a bunch of seed data for artists and songs" | |
task :seed_artists_and_songs => [:environment, :clear_artists_and_songs] do | |
# Build Song Off Artist | |
# Given a Song called R.E.S.P.E.C.T | |
# build the Aretha Franklin Artist | |
s = Song.create(:name => "R.E.S.P.E.C.T") | |
s.build_artist(:name => "Aretha Franklin") | |
s.save | |
# Build a Song for that Artist | |
# build song Natural Woman | |
# Manually Create Artist Kanye West | |
# Push a Song Onto an Artist | |
# push a song onto Kanye West | |
# Create Michael Jackson Artist | |
# Make 3 Michael Jackson Songs | |
# push all songs by Michael Jackson | |
# Delete one michael song off of michael | |
# Remove a Song from Artist | |
end | |
task :clear_artists_and_songs => [:environment] do | |
puts "Deleting all Artists and Songs...." | |
Artist.delete_all | |
Song.delete_all | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment