31 lines
1.1 KiB
Ruby
31 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# Lessons
|
|
class Lesson < ApplicationRecord
|
|
# == Constants ============================================================
|
|
|
|
# == Attributes ===========================================================
|
|
|
|
# == Extensions ===========================================================
|
|
|
|
# == Relationships ========================================================
|
|
belongs_to :course
|
|
belongs_to :week
|
|
belongs_to :video, optional: true
|
|
|
|
# == Validations ==========================================================
|
|
validates :name, presence: true
|
|
|
|
# == Scopes ===============================================================
|
|
scope :by_course, ->(c_id) { where(course_id: c_id) }
|
|
scope :by_week, ->(w_id) { where(week_id: w_id) }
|
|
scope :name_asc, -> { order(:name) }
|
|
scope :name_desc, -> { order(name: :desc) }
|
|
|
|
# == Callbacks ============================================================
|
|
|
|
# == Class Methods ========================================================
|
|
|
|
# == Instance Methods =====================================================
|
|
end
|