2011-06-14 20:05:12 +04:00
|
|
|
class Track < ActiveRecord::Base
|
2011-06-15 00:01:42 +04:00
|
|
|
belongs_to :album
|
2011-09-26 04:05:46 +04:00
|
|
|
has_many :track_artists
|
2011-09-22 19:40:44 +04:00
|
|
|
has_many :artists, :through => :track_artists
|
2011-10-20 15:01:57 +04:00
|
|
|
@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
|
2011-06-14 20:05:12 +04:00
|
|
|
end
|