Tunr 1.0!

Local Setup

$ createdb tunr_db
$ psql -d tunr_db < db/schema.sql

Part 1.1 - Create the Artist Model using Active Record

  1. Create an app.rb file for this application
  2. Create a Gemfile using bundle init
  3. Create a folder for your models (it should be called models)
  4. Create a file that will contain your AR class definition for 'artists'
  5. Add your dependencies into the Gemfile and then run bundle install

Part 1.2 - Define artists & setup your app.rb to connect to the database

  1. Define your artist model in models/artist.rb
  2. Require your dependencies in app.rb
  3. Establish connection to database using AR
  4. Load pry at the end of app.rb

Part 1.3 - Use your Artist Model

Remember to seed your database before running the commands below

$ psql -d tunr_db < db/seeds.sql

In the console:

  1. Find all artists
  2. Find just one artist by id
  3. Find Taylor Swift (or your other fav artist) by name.
  4. Find all artists from the USA
  5. Find all artists NOT from the USA
  6. Create a new artist for your favorite artist
  7. Change at least 2 of their attributes
  8. Destroy the artist you just created
  • (NOTE: If you destroy other artists at this point, you'll need to reseed your data for consistency.)

Part 1.4 - Create your Song Model / Setup Associations

  1. Create a file that will contain your AR class definition for Songs
  2. Make sure to link that file in your main application file
  3. Add corresponding associations to your models

Part 1.5 - Use your Model Associations

In the console...

  1. Find the artist with the name Enya
  2. Use AR methods to find all of Enya's songs, store them in a variable
  3. Get the first song out of those results and get that song's title
  4. Find the song with the title 'Unstoppable' and store in a variable
  5. Get that song's artist, store that in a variable
  6. Reassign the song's artist to be a different one (your choice)
  7. Save that song
  8. Create a new song, and associate it with a different artist of your choice
  9. Delete that song
  10. Find all of Enya's songs again, store in a variable
  • Using each, iterate over those songs and for each song, print "I like" + the song name