module JamRuby
  class Instrument < ActiveRecord::Base

    self.primary_key = 'id'

    # users
    has_many :musician_instruments, :class_name => "JamRuby::MusicianInstrument"
    has_many :users, :through => :musician_instruments, :class_name => "JamRuby::User"
    has_many :tracks, :class_name => "JamRuby::Track", :inverse_of => :instrument
    has_many :recorded_tracks, :class_name => "JamRuby::RecordedTrack", :inverse_of => :instrument

    # music sessions
    has_and_belongs_to_many :music_sessions, :class_name => "JamRuby::MusicSession", :join_table => "genres_music_sessions"

    def self.standard_list
      return Instrument.where('instruments.popularity > 0').order('instruments.popularity DESC, instruments.description ASC')
    end

  end
end
