Class: PartyTopic
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PartyTopic
- Includes:
- Models::Auditable
- Defined in:
- app/models/party_topic.rb
Overview
== Schema Information
Table name: party_topics
Database name: primary
id :integer not null, primary key
comments :text
due_on :datetime
follow_up :boolean
instruction_type :enum
position :integer
state :string(20)
state_created_at :datetime
type :string(20)
created_at :datetime not null
updated_at :datetime not null
course_category_id :integer
course_enrollment_id :integer
course_exam_id :integer
creator_id :integer
party_id :integer not null
survey_enrollment_id :integer
topic_id :integer not null
trainer_party_id :integer
updater_id :integer
Indexes
index_party_topic_enrollment_and_exam (party_id,topic_id,course_enrollment_id,course_exam_id)
index_party_topics_on_topic_id (topic_id)
index_party_topics_on_type (type)
party_topics_trainer_party_id_idx (trainer_party_id)
Foreign Keys
fk_rails_... (party_id => parties.id) ON DELETE => cascade
fk_rails_... (topic_id => topics.id) ON DELETE => cascade
fk_rails_... (trainer_party_id => parties.id) ON DELETE => nullify
Direct Known Subclasses
Constant Summary collapse
- STATES =
States.
%i[assigned in_progress completed cancelled].freeze
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Belongs to collapse
Methods included from Models::Auditable
Class Method Summary collapse
-
.assigned ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are assigned.
-
.completed ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are completed.
-
.in_progress ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are in progress.
-
.ongoing ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are ongoing.
-
.sorted ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are sorted.
Instance Method Summary collapse
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Class Method Details
.assigned ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are assigned. Active Record Scope
60 |
# File 'app/models/party_topic.rb', line 60 scope :assigned, -> { where(state: :assigned) } |
.completed ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are completed. Active Record Scope
59 |
# File 'app/models/party_topic.rb', line 59 scope :completed, -> { where(state: :completed) } |
.in_progress ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are in progress. Active Record Scope
58 |
# File 'app/models/party_topic.rb', line 58 scope :in_progress, -> { where(state: :in_progress) } |
.ongoing ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are ongoing. Active Record Scope
61 |
# File 'app/models/party_topic.rb', line 61 scope :ongoing, -> { where(state: %i[in_progress assigned]) } |
.sorted ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are sorted. Active Record Scope
62 63 64 65 |
# File 'app/models/party_topic.rb', line 62 scope :sorted, -> { joins(:topic) .order('topics.position, topics.title') } |
Instance Method Details
#complete ⇒ Object
67 68 69 |
# File 'app/models/party_topic.rb', line 67 def complete update(state: 'completed') end |
#party ⇒ Party
Validations:
44 |
# File 'app/models/party_topic.rb', line 44 belongs_to :party, inverse_of: :party_topics, optional: true |
#topic ⇒ Topic
Validations:
- Uniqueness ({ scope: %i[party_id type course_enrollment_id course_exam_id survey_enrollment_id] })
45 |
# File 'app/models/party_topic.rb', line 45 belongs_to :topic, inverse_of: :party_topics, optional: true |