2014-08-10 21:17:06 +03:00
|
|
|
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-08-30 17:31:29 +03:00
|
|
|
validates :track, inclusion: { in: (Conference.current.try(:tracks) || []) }
|
2014-08-10 21:17:06 +03:00
|
|
|
|
|
|
|
belongs_to :track
|
|
|
|
has_one :conference, through: :track
|
|
|
|
belongs_to :user
|
2014-09-02 18:11:35 +03:00
|
|
|
|
|
|
|
after_create :send_new_event_notification
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def send_new_event_notification
|
|
|
|
EventMailer.new_event_notification(self).deliver
|
|
|
|
end
|
2014-08-10 21:17:06 +03:00
|
|
|
end
|