module JamRuby
  class BackingTrack < ActiveRecord::Base

    self.table_name = "backing_tracks"
    self.primary_key = 'id'

    default_scope { order('created_at ASC') }

    belongs_to :connection, :class_name => "JamRuby::Connection", :inverse_of => :tracks, :foreign_key => 'connection_id'
    validates :connection, presence: true
    validates :client_track_id, presence: true
    validates :filename, presence: true

    def user
      self.connection.user
    end

  end
end