clarion/app/models/event.rb
Petko Bordjukov 9ca34c5a22 Introduce a Participation model
This model is responsible for the 1..n - 1..n relationship between an
event and the people that will participate in it.
2015-07-31 14:40:04 +03:00

26 lines
843 B
Ruby

class Event < ActiveRecord::Base
include Proposable
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
has_one :conference, through: :track
has_many :participations
has_many :pending_participations, ->() { pending }, class_name: 'Participation'
has_many :approved_participations, ->() { approved }, class_name: 'Participation'
has_many :participants, through: :approved_participations
belongs_to :event_type
validates :title, presence: true
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
validates :abstract, presence: true
validates :description, presence: true
validates :agreement, acceptance: true
scope :confirmed, -> { where.not confirmed_at: nil }
def proposer_profile
proposer.personal_profile(conference)
end
end