Skip to content

Commit

Permalink
added doc for using Searchkick.pagy_search (closes #319)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jun 25, 2021
1 parent ca74132 commit 28983e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/extras/searchkick.md
Expand Up @@ -13,6 +13,7 @@ Require the extra in the `pagy.rb` initializer:

```ruby
require 'pagy/extras/searchkick'
Searchkick.extend Pagy::Searchkick # optional
```

### Passive mode
Expand Down Expand Up @@ -40,6 +41,22 @@ In a controller use `pagy_search` in place of `search`:
results = Article.pagy_search(params[:q])
@pagy, @results = pagy_searchkick(results, items: 10)
```

#### Searchkick.search

Extend also the `Searchkick` module if you are going to use `Searchkick.pagy_search`:

```ruby
# config/initializers/pagy.rb
Searchkick.extend Pagy::Searchkick
```

Use `pagy_search` in place of `search`:

```ruby
results = Searchkick.pagy_search(params[:q], models: [Article, Categories])
@pagy, @results = pagy_searchkick(results, items: 10)
```

## Files

Expand Down
3 changes: 3 additions & 0 deletions lib/config/pagy.rb
Expand Up @@ -56,6 +56,9 @@
# also the elasticsearch_rails extra that defines the same
# VARS[:searchkick_search_method] = :pagy_search
# require 'pagy/extras/searchkick'
# uncomment if you are going to use Searchkick.pagy_search
# Searchkick.extend Pagy::Searchkick


# Frontend Extras

Expand Down

1 comment on commit 28983e6

@leemcalilly
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks so much @ddnexus !

Please sign in to comment.