beathaven/app/models/track.rb

18 lines
431 B
Ruby
Raw Normal View History

2012-08-27 03:53:30 +04:00
class Track < ActiveRecord::Base
belongs_to :album
has_many :performers
has_many :artists, through: :performers
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title
scope :with_artists, lambda{
includes(:artists)
}
2012-08-27 03:53:30 +04:00
def length
return if duration.nil?
length = duration.divmod(60).map(&:to_s)
length[1] = "0" << length[1] if length[1].length == 1
length.join(":")
end
end