Class: System::Admin::Instance::CoursesController

Inherits:
Controller
  • Object
show all
Defined in:
app/controllers/system/admin/instance/courses_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject


15
16
17
18
19
20
21
22
# File 'app/controllers/system/admin/instance/courses_controller.rb', line 15

def destroy
  if @course.destroy
    redirect_to admin_instance_courses_path, success: t('.success', course: @course.title)
  else
    redirect_to admin_instance_courses_path,
                danger: t('.failure', error: @course.errors.full_messages.to_sentence)
  end
end

#indexObject


7
8
9
10
11
12
13
# File 'app/controllers/system/admin/instance/courses_controller.rb', line 7

def index
  @courses = @instance.courses.search(search_param).calculated(:active_user_count, :user_count)
  @courses = @courses.active_in_past_7_days.order('active_user_count DESC, user_count') if params[:active]
  @courses = @courses.ordered_by_title.page(page_param)

  @owner_preload_service = Course::CourseOwnerPreloadService.new(@courses.map(&:id))
end