Class: Lcms::Engine::Admin::ResourcePickerController

Inherits:
AdminController show all
Defined in:
app/controllers/lcms/engine/admin/resource_picker_controller.rb

Constant Summary

Constants inherited from AdminController

AdminController::RE_GOOGLE_FOLDER

Instance Method Summary collapse

Methods inherited from AdminController

settings

Methods included from PathHelper

#dynamic_document_path, #dynamic_material_path, #dynamic_path

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/lcms/engine/admin/resource_picker_controller.rb', line 7

def index
  @resources = Resource.where(nil)

  @resources = @resources.where_subject(index_params[:subject]) if index_params[:subject].present?
  @resources = @resources.where(curriculum_type: index_params[:type]) if index_params[:type].present?
  @resources = @resources.where_grade(grade_name) if index_params[:grade].present?
  @resources = @resources.where('title ilike ?', "%#{params[:q]}%") if index_params[:q].present?

  @resources = @resources.paginate(pagination.params(strict: true)).order('resources.title asc')

  respond_to do |format|
    format.json { render json: pagination.serialize(@resources, ResourcePickerSerializer) }
  end
end