#
#
:searchkick
:searchkick
is a paginator for Searchkick::Results
objects.
pagy.rb (initializer)
Searchkick.extend Pagy::Search
Pagy searches and paginates
Use the pagy_search
method instead of the search
method.
Model
extend Pagy::Search
Controller
# Single model
search = Article.pagy_search(params[:q])
# Multi models
search = Searchkick.pagy_search(params[:q], models: [Article, Categories])
# Paginate it
@pagy, @response = pagy(:searchkick, search, **options)
You search and paginate
Pagy creates its object out of your result.
Controller
# Standard results (already paginated)
@results = Article.search('*', page: 1, per_page: 10, ...)
# Get the pagy object out of it
@pagy = pagy(:searchkick, @results, **options)
Search paginators don't query a DB, but use the same positional technique as :offset paginators, with shared options and readers.
search_method: :my_search
- Customize the name of the search method (default
:search
)
- Customize the name of the search method (default
See also Offset Options
See Offset Readers