Class: EventAuthor

Inherits:
ApplicationRecord show all
Defined in:
app/models/event_author.rb

Overview

== Schema Information

Table name: event_authors
Database name: primary

id :bigint not null, primary key
event_id :bigint not null
employee_id :bigint not null
created_at :datetime not null
updated_at :datetime not null

Indexes

idx_event_authors_unique (event_id,employee_id) UNIQUE
idx_event_authors_lookup (employee_id,event_id)

Foreign Keys

fk_rails_... (event_id => events.id) ON DELETE => cascade
fk_rails_... (employee_id => parties.id) ON DELETE => restrict

Join table: one row per (event, employee-author) pairing on the marketing
calendar. Replaces the legacy single events.creator_id association so an
event can be co-owned by multiple employees. The DB-level unique index plus
the model-level uniqueness validation give a friendly error when the same
employee is added twice to the same event.

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#employee_idObject (readonly)



33
# File 'app/models/event_author.rb', line 33

validates :employee_id, uniqueness: { scope: :event_id }

Instance Method Details

#employeeEmployee

Returns:

See Also:



31
# File 'app/models/event_author.rb', line 31

belongs_to :employee, class_name: 'Employee', inverse_of: :event_authors

#eventEvent

Returns:

See Also:



30
# File 'app/models/event_author.rb', line 30

belongs_to :event