1
0
Fork 0
oldhaven/app/models/beathaven/playlist.rb

14 lines
302 B
Ruby

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