Models rubocop and clleanup
This commit is contained in:
parent
75df7a2968
commit
006a1a5b39
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Application Record
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Course
|
||||
class Course < ApplicationRecord
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
||||
# == Extensions ===========================================================
|
||||
|
||||
# == Relationships ========================================================
|
||||
has_many :weeks, dependent: :destroy
|
||||
|
||||
# == Validations ==========================================================
|
||||
validates :name, presence: true
|
||||
|
||||
scope :name_asc, -> { order('name ASC') }
|
||||
# == Scopes ===============================================================
|
||||
scope :name_asc, -> { order(:name) }
|
||||
|
||||
# == Callbacks ============================================================
|
||||
|
||||
# == Class Methods ========================================================
|
||||
|
||||
# == Instance Methods =====================================================
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Landing Course Page
|
||||
class CourseLandingPage < ApplicationRecord
|
||||
belongs_to :course
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Email SMTP Account Configurations
|
||||
class EmailAccount < ApplicationRecord
|
||||
enum authentication: %i[plain login cram_md5]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,2 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# LeadEmail
|
||||
class LeadEmail < ApplicationRecord
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Lessons
|
||||
class Lesson < ApplicationRecord
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
||||
# == Extensions ===========================================================
|
||||
|
||||
# == Relationships ========================================================
|
||||
belongs_to :course
|
||||
belongs_to :week
|
||||
belongs_to :video
|
||||
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 ============================================================
|
||||
before_create :b_create
|
||||
|
||||
# == Class Methods ========================================================
|
||||
|
||||
# == Instance Methods =====================================================
|
||||
def b_create
|
||||
self.course = week.course
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# User
|
||||
class User < ApplicationRecord
|
||||
validates :email, uniqueness: true
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
||||
# == Extensions ===========================================================
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable,
|
||||
# :registerable
|
||||
devise :database_authenticatable, :confirmable, :trackable, :timeoutable,
|
||||
:recoverable, :rememberable, :validatable, :lockable, :registerable
|
||||
|
||||
# == Relationships ========================================================
|
||||
|
||||
# == Validations ==========================================================
|
||||
validates :email, uniqueness: true
|
||||
|
||||
# == Scopes ===============================================================
|
||||
scope :email_asc, -> { order(email) }
|
||||
# == Callbacks ============================================================
|
||||
|
||||
# == Class Methods ========================================================
|
||||
|
||||
# == Instance Methods =====================================================
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# User Activity
|
||||
class UserActivity < ApplicationRecord
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# User Additional Data
|
||||
class UserAdd < ApplicationRecord
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Class for video links
|
||||
class Video < ApplicationRecord
|
||||
belongs_to :video_account
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Video Accunt Settings
|
||||
class VideoAccount < ApplicationRecord
|
||||
belongs_to :account, polymorphic: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,11 +2,26 @@
|
|||
|
||||
# Weeks
|
||||
class Week < ApplicationRecord
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
||||
# == Extensions ===========================================================
|
||||
|
||||
# == Relationships ========================================================
|
||||
belongs_to :course
|
||||
|
||||
# == Validations ==========================================================
|
||||
validates :name, presence: true
|
||||
|
||||
# == Scopes ===============================================================
|
||||
scope :by_course, ->(c_id) { where(course_id: c_id) }
|
||||
scope :name_asc, -> { order('name ASC') }
|
||||
scope :name_desc, -> { order('name DESC') }
|
||||
scope :name_asc, -> { order(name) }
|
||||
scope :name_desc, -> { order(name: :desc) }
|
||||
|
||||
# == Callbacks ============================================================
|
||||
|
||||
# == Class Methods ========================================================
|
||||
|
||||
# == Instance Methods =====================================================
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue