Class: CourseCategory

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/course_category.rb

Overview

== Schema Information

Table name: course_categories
Database name: primary

id :bigint not null, primary key
extra_note :string
position :integer
state :string
created_at :datetime not null
updated_at :datetime not null
course_enrollment_id :integer
topic_category_id :integer

Indexes

index_course_categories_on_course_enrollment_id (course_enrollment_id)

Foreign Keys

fk_rails_... (course_enrollment_id => course_enrollments.id)

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Has many collapse

Class Method Summary collapse

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

#publish_event

Class Method Details

.activeActiveRecord::Relation<CourseCategory>

A relation of CourseCategories that are active. Active Record Scope

Returns:

See Also:



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

scope :active, -> { where(active: true) }

.sortedActiveRecord::Relation<CourseCategory>

A relation of CourseCategories that are sorted. Active Record Scope

Returns:

See Also:



34
# File 'app/models/course_category.rb', line 34

scope :sorted, -> { order(:position) }

Instance Method Details

#course_enrollmentCourseEnrollment



28
# File 'app/models/course_category.rb', line 28

belongs_to :course_enrollment, optional: true

#customer_topicsActiveRecord::Relation<CustomerTopic>

Returns:

See Also:



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

has_many :customer_topics, -> { order(:position) }, inverse_of: :course_category

#nextObject



36
37
38
# File 'app/models/course_category.rb', line 36

def next
  course_enrollment.course_categories.order(:position).where(position: position + 1)&.first
end

#topic_categoryTopicCategory



29
# File 'app/models/course_category.rb', line 29

belongs_to :topic_category, optional: true