class DoctrinesController < ApplicationController load_and_authorize_resource :doctrine, class: "Doctrine" def index @search = search_doctrines(search_params) @doctrines = @search.results respond_to do |format| format.html end end def search @search = search_doctrines(search_params) @doctrines = @search.results respond_to do |format| format.html end end def show; end private def search_doctrines(args) Doctrine.search do if args[:subject_ids].present? with(:subject_ids).any_of(args[:subject_ids].map(&:to_i)) end paginate page: args[:page] || 1, per_page: args[:per_page] || 100 end end def search_params params.permit(subject_ids: []) end end