0.0
No release in over a year
Gem to simplify AR queries, it executes query and includes relations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

AbstractFinder

API wrapper for search, pagination, filter.

General idea to pass a query, relations to avoid N+1 and permitted params to paginate, filter and sort AbstractFinder collection.

class RecordsContrroller < Api::BaseController
  def index
    finder = AbstractFinder.call(
      Record.latest,     # scope, method or a class
      %w[rating status], # to fight N+1
      params             # permitted params for pagination, filtering, ordering and search
    )

    render json: RecordSerializer.new(
      finder.collection,
      { meta: finder.meta, params: permitted_params }
    ).serializable_hash
  end

  private

  def params
    params.require(:record).permit(:page, :per_page, :search_by, :q, :order_by)
  end
end