Class: CourseCategory
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CourseCategory
- 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
Has many collapse
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<CourseCategory>
A relation of CourseCategories that are active.
-
.sorted ⇒ ActiveRecord::Relation<CourseCategory>
A relation of CourseCategories 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
.active ⇒ ActiveRecord::Relation<CourseCategory>
A relation of CourseCategories that are active. Active Record Scope
33 |
# File 'app/models/course_category.rb', line 33 scope :active, -> { where(active: true) } |
.sorted ⇒ ActiveRecord::Relation<CourseCategory>
A relation of CourseCategories that are sorted. Active Record Scope
34 |
# File 'app/models/course_category.rb', line 34 scope :sorted, -> { order(:position) } |
Instance Method Details
#course_enrollment ⇒ CourseEnrollment
28 |
# File 'app/models/course_category.rb', line 28 belongs_to :course_enrollment, optional: true |
#customer_topics ⇒ ActiveRecord::Relation<CustomerTopic>
31 |
# File 'app/models/course_category.rb', line 31 has_many :customer_topics, -> { order(:position) }, inverse_of: :course_category |
#next ⇒ Object
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_category ⇒ TopicCategory
29 |
# File 'app/models/course_category.rb', line 29 belongs_to :topic_category, optional: true |