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