@ -82,6 +82,7 @@ class Course < ApplicationRecord
scope :by_keywords, lambda { |keywords|
where("name LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
scope :started, -> { where("start_date is null or start_date <= '#{Date.today}'") }
acts_as_taggable
@ -23,11 +23,11 @@ class Users::CourseService
def category_scope_courses
case params[:category]
when 'study' then
user.as_student_courses
user.as_student_courses.started
when 'manage' then
user.manage_courses
else
ids = user.as_student_courses.pluck(:id) + user.manage_courses.pluck(:id)
ids = user.as_student_courses.started.pluck(:id) + user.manage_courses.pluck(:id)
Course.where(id: ids)
end