osem-fcy/app/models/events_registration.rb

33 lines
749 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2021-02-20 09:57:27 -08:00
# == Schema Information
#
# Table name: events_registrations
#
# id :bigint not null, primary key
# attended :boolean default(FALSE), not null
# created_at :datetime
# event_id :integer
# registration_id :integer
#
class EventsRegistration < ApplicationRecord
belongs_to :registration
belongs_to :event
2016-04-22 18:18:46 +03:00
has_one :user, through: :registration
has_paper_trail meta: { conference_id: :conference_id }
2016-04-22 18:18:46 +03:00
delegate :name, to: :registration
delegate :email, to: :registration
validates :event, :registration, presence: true
validates :event, uniqueness: { scope: :registration }
private
def conference_id
registration.conference_id
end
end