Class: Course

Inherits:
ApplicationRecord show all
Extended by:
FriendlyId
Includes:
Models::Auditable, Models::LiquidMethods
Defined in:
app/models/course.rb

Overview

+----------+ +---------------+ +-------+ +---------+
| | 1 * | | 1 * | | 1 * | |
| Course +-----+ TopicCategory +-----+ Topic +-----+ Article |
| | | (Module) | | | | |
+----------+ +---------------+ +-------+ +---------+
== Schema Information

Table name: courses
Database name: primary

id :bigint not null, primary key
active :boolean default(TRUE)
description :text
duration :string
name :string not null
slug :string
created_at :datetime not null
updated_at :datetime not null
creator_id :integer
updater_id :integer

Indexes

index_courses_on_slug (slug) UNIQUE

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Instance Attribute Summary collapse

Has many collapse

Class Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#nameObject (readonly)



39
# File 'app/models/course.rb', line 39

validates :name, presence: true, uniqueness: true

Class Method Details

.activeActiveRecord::Relation<Course>

A relation of Courses that are active. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Course>)

See Also:



43
# File 'app/models/course.rb', line 43

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

.select_options(course_id: nil) ⇒ Object



45
46
47
# File 'app/models/course.rb', line 45

def self.select_options(course_id: nil)
  Course.all.pluck(:name, :id)
end

Instance Method Details

#course_enrollmentsActiveRecord::Relation<CourseEnrollment>

Returns:

See Also:



36
# File 'app/models/course.rb', line 36

has_many :course_enrollments

#party_topicsActiveRecord::Relation<PartyTopic>

Returns:

See Also:



37
# File 'app/models/course.rb', line 37

has_many :party_topics

#topic_categoriesActiveRecord::Relation<TopicCategory>

Returns:

See Also:



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

has_many :topic_categories

#topic_examsActiveRecord::Relation<TopicExam>

Returns:

See Also:



35
# File 'app/models/course.rb', line 35

has_many :topic_exams