|
class Playlist < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :artist
|
|
has_many :playlist_items, dependent: :destroy
|
|
|
|
def serialize
|
|
data = {name: name, pic_url: pic_url, tracks: []}
|
|
playlist_items.each do |item|
|
|
data[:tracks] << item.track.serialize
|
|
end
|
|
data
|
|
end
|
|
end
|