29 lines
915 B
Ruby
29 lines
915 B
Ruby
module JamRuby
|
|
class RsvpSlot < ActiveRecord::Base
|
|
|
|
belongs_to :instrument, :class_name => "JamRuby::Instrument"
|
|
belongs_to :music_session
|
|
has_many :rsvp_requests_rsvp_slots, :class_name => "JamRuby::RsvpRequestRsvpSlot", :foreign_key => "rsvp_slot_id"
|
|
has_many :rsvp_requests, :class_name => "JamRuby::RsvpRequest", :through => :rsvp_requests_rsvp_slots
|
|
|
|
attr_accessor :chosen
|
|
|
|
# TODO: validates :proficiency_level
|
|
|
|
def self.index(music_session)
|
|
RsvpSlot.where("music_session_id = ?", music_session.id)
|
|
end
|
|
|
|
def chosen
|
|
chosen_slots = RsvpRequestRsvpSlot.where("chosen = true AND rsvp_slot_id = ?", self.id)
|
|
!chosen_slots.blank?
|
|
end
|
|
|
|
# def has_rsvp_from_user(user)
|
|
# user_slot = RsvpRequest.joins(:rsvp_requests_rsvp_slots)
|
|
# .where(:rsvp_request_id => )
|
|
# .where(:user_id => user.id)
|
|
# end
|
|
end
|
|
end
|