2011-09-26 04:48:31 +04:00

13 lines
371 B
Ruby

class Album < ActiveRecord::Base
belongs_to :artist
has_many :tracks, :order => 'bonus ASC, position ASC', :dependent => :destroy
has_many :album_formats
has_many :release_formats, :through => :album_formats
default_scope where(:master => true)
def self.with_format f
joins(:release_formats).where(:release_formats => { :hash => f.to_s })
end
end