Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/models/artist.rb
Expand Up @@ -3,14 +3,14 @@ class Artist < ActiveRecord::Base
has_many :genres, through: :songs

def get_genre_of_first_song
#return the genre of the artist's first saved song
self.songs.first.genre
end

def song_count
#return the number of songs associated with the artist
self.songs.count
end

def genre_count
#return the number of genres associated with the artist
self.genres.count
end
end
6 changes: 3 additions & 3 deletions app/models/genre.rb
Expand Up @@ -3,14 +3,14 @@ class Genre < ActiveRecord::Base
has_many :artists, through: :songs

def song_count
# return the number of songs in a genre
self.songs.count
end

def artist_count
# return the number of artists associated with the genre
self.artists.count
end

def all_artist_names
# return an array of strings containing every musician's name
self.artists.collect {|a| a.name}
end
end
5 changes: 3 additions & 2 deletions app/models/song.rb
Expand Up @@ -3,9 +3,10 @@ class Song < ActiveRecord::Base
belongs_to :genre

def get_genre_name
self.genre.name
end

def drake_made_this
# when this method is called it should assign the song's artist to Drake
self.artist = Artist.find_or_create_by(name: "Drake")
end
end
end
Binary file added db/playlister-development.db
Binary file not shown.
Binary file added db/playlister-test.db
Binary file not shown.