2011-06-14 16:05:12 +00:00
|
|
|
class Track < ActiveRecord::Base
|
2011-06-14 20:01:42 +00:00
|
|
|
belongs_to :album
|
2011-09-26 00:05:46 +00:00
|
|
|
has_many :track_artists
|
2011-09-22 15:40:44 +00:00
|
|
|
has_many :artists, :through => :track_artists
|
2011-11-26 15:03:33 +00:00
|
|
|
has_many :playlist_items
|
2011-10-20 11:01:57 +00:00
|
|
|
|
|
|
|
def duration
|
|
|
|
if self.length
|
|
|
|
time = self.length
|
|
|
|
time_m = (time / 60).floor
|
|
|
|
time_s = time - time_m * 60
|
|
|
|
time_m.to_s + ':' + (time_s < 10 ? '0' : '') + time_s.to_s
|
|
|
|
else
|
|
|
|
'0:00'
|
|
|
|
end
|
|
|
|
end
|
2011-06-14 16:05:12 +00:00
|
|
|
end
|