Class: Iron::Api::SearchController

Inherits:
BaseController
  • Object
show all
Includes:
CursorPagination
Defined in:
app/controllers/iron/api/search_controller.rb

Constant Summary

Constants included from CursorPagination

CursorPagination::DEFAULT_PER_PAGE, CursorPagination::MAX_PER_PAGE

Instance Method Summary collapse

Instance Method Details

#showObject



6
7
8
9
10
11
12
# File 'app/controllers/iron/api/search_controller.rb', line 6

def show
  return render json: { error: "Missing required parameter: q" }, status: :bad_request if params[:q].blank?

  scope = Entry.search(params[:q], locale: Current.locale)
    .includes(:fields, content_type: :field_definitions)
  @collection = paginate(scope)
end