Class: TopicExam

Inherits:
ApplicationRecord show all
Defined in:
app/models/topic_exam.rb

Overview

== Schema Information

Table name: topic_exams
Database name: primary

id :bigint not null, primary key
active :boolean default(FALSE), not null
applies_to_customers :boolean default(FALSE), not null
applies_to_employees :boolean default(FALSE), not null
description :text
min_score_to_pass :integer
name :string not null
position :integer
training_module :boolean default(FALSE), not null
course_id :integer not null
topic_category_id :integer

Foreign Keys

fk_rails_... (topic_category_id => topic_categories.id)

Instance Attribute Summary collapse

Belongs to collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#min_score_to_passObject (readonly)



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

validates :min_score_to_pass, presence: true

Class Method Details

.activeActiveRecord::Relation<TopicExam>

A relation of TopicExams that are active. Active Record Scope

Returns:

See Also:



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

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

.select_optionsObject



38
39
40
# File 'app/models/topic_exam.rb', line 38

def self.select_options
  order(:name).map{|te| [te.to_s, te.id]}
end

.sortedActiveRecord::Relation<TopicExam>

A relation of TopicExams that are sorted. Active Record Scope

Returns:

See Also:



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

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

Instance Method Details

#courseCourse

Returns:

See Also:



24
# File 'app/models/topic_exam.rb', line 24

belongs_to :course, optional: true

#customer_topicsActiveRecord::Relation<CustomerTopic>

Returns:

See Also:



27
# File 'app/models/topic_exam.rb', line 27

has_many :customer_topics

#to_sObject



42
43
44
# File 'app/models/topic_exam.rb', line 42

def to_s
  name
end

#topicsActiveRecord::Relation<Topic>

Returns:

  • (ActiveRecord::Relation<Topic>)

See Also:



26
# File 'app/models/topic_exam.rb', line 26

has_many :topics, -> { order(:position) }, inverse_of: :topic_exam