clarion/app/models/event.rb

22 lines
717 B
Ruby
Raw Normal View History

class Event < ActiveRecord::Base
validates :title, presence: true
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
validates :abstract, presence: true
validates :description, presence: true
2014-09-07 00:02:00 +03:00
validates :track_id, inclusion: { in: (Conference.current.try(:tracks) || []).map(&:id) }
2014-09-04 00:39:54 +03:00
validates :agreement, acceptance: true
belongs_to :track
has_one :conference, through: :track
belongs_to :user # XXX: Transition to candidate_speaker
belongs_to :candidate_speaker, class_name: 'User', foreign_key: 'user_id'
after_create :send_new_event_notification
private
def send_new_event_notification
EventMailer.new_event_notification(self).deliver
end
end