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 :integer
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 =
%i[assigned in_progress completed cancelled]
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
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.
-
.exams ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are exams.
-
.for_topic_category ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are for topic category.
-
.in_progress ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are in progress.
-
.no_exams ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are no exams.
-
.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 Models::EventPublishable
Class Method Details
.assigned ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are assigned. Active Record Scope
53 |
# File 'app/models/party_topic.rb', line 53 scope :assigned, -> { where(state: :assigned)} |
.completed ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are completed. Active Record Scope
52 |
# File 'app/models/party_topic.rb', line 52 scope :completed, -> { where(state: :completed)} |
.exams ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are exams. Active Record Scope
58 |
# File 'app/models/party_topic.rb', line 58 scope :exams, -> { where.not(topic_exam_id: nil)} |
.for_topic_category ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are for topic category. Active Record Scope
59 |
# File 'app/models/party_topic.rb', line 59 scope :for_topic_category, -> (tc) { where(party_topics: {topic_category_id: tc.id}).sorted} |
.in_progress ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are in progress. Active Record Scope
51 |
# File 'app/models/party_topic.rb', line 51 scope :in_progress, -> { where(state: :in_progress)} |
.no_exams ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are no exams. Active Record Scope
57 |
# File 'app/models/party_topic.rb', line 57 scope :no_exams, -> { where.not(topic_category_id: nil)} |
.ongoing ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are ongoing. Active Record Scope
54 |
# File 'app/models/party_topic.rb', line 54 scope :ongoing, -> { where(state: [:in_progress, :assigned])} |
.sorted ⇒ ActiveRecord::Relation<PartyTopic>
A relation of PartyTopics that are sorted. Active Record Scope
55 56 |
# File 'app/models/party_topic.rb', line 55 scope :sorted, -> { joins(:topic). order('topics.position, topics.title') } |
Instance Method Details
#complete ⇒ Object
61 62 63 |
# File 'app/models/party_topic.rb', line 61 def complete self.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
45 |
# File 'app/models/party_topic.rb', line 45 belongs_to :topic, inverse_of: :party_topics, optional: true |