2011-10-20 15:01:57 +04:00

18 lines
373 B
Ruby

class Track < ActiveRecord::Base
belongs_to :album
has_many :track_artists
has_many :artists, :through => :track_artists
@duration
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
end