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