Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typos in searchkick readme #129

Merged
merged 2 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/extras/searchkick.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ See [extras](../extras.md) for general usage info.
Require the extra in the `pagy.rb` initializer:

```ruby
require 'pagy/extras/searchkik'
require 'pagy/extras/searchkick'
```

### Passive mode
Expand All @@ -21,7 +21,7 @@ If you have an already paginated `Searchkick::Results` object, you can get the `

```ruby
@results = Model.search('*', from: 0; size: 10, ...)
@pagy = Pagy.new_from_searchkik(@results, ...)
@pagy = Pagy.new_from_searchkick(@results, ...)
```

### Active Mode
Expand All @@ -38,22 +38,22 @@ In a controller use `pagy_search` in place of `search`:

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

## Files

This extra is composed of 1 file:

- [searchkik.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/searchkik.rb)
- [searchkick.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/searchkick.rb)

## Pagy.new_from_searchkick

This constructor accepts an `Searchkick::Results` as the first argument, plus the usual optional variable hash. It sets the `:items`, `:page` and `:count` pagy variables extracted/calculated out of the `Searchkick::Results` object.

```ruby
@results = Model.search('*', page: 2; per_page: 10, ...)
@pagy = Pagy.new_from_searchkik(@results, ...)
@pagy = Pagy.new_from_searchkick(@results, ...)
```

**Notice**: you have to take care of managing all the params manually. If you prefer to manage the pagination automatically, see below.
Expand All @@ -74,23 +74,23 @@ This method accepts the same arguments of the `search` method and you must use i

## Methods

This extra adds the `pagy_searchkick` method to the `Pagy::Backend` to be used when you have to paginate a `Searchkick::Results` object. It also adds a `pagy_searchkik_get_variables` sub-method, used for easy customization of variables by overriding.
This extra adds the `pagy_searchkick` method to the `Pagy::Backend` to be used when you have to paginate a `Searchkick::Results` object. It also adds a `pagy_searchkick_get_variables` sub-method, used for easy customization of variables by overriding.

### pagy_searchkik(Model.pagy_search(...), vars={}})
### pagy_searchkick(Model.pagy_search(...), vars={}})

This method is similar to the generic `pagy` method, but specialized for Searchkick. (see the [pagy doc](../api/backend.md#pagycollection-varsnil))

It expects to receive a `Model.pagy_search(...)` result and returns a paginated response. You can use it in a couple of ways:

```ruby
@pagy, @results = pagy_searchkik(Model.pagy_search(params[:q]), ...)
@pagy, @results = pagy_searchkick(Model.pagy_search(params[:q]), ...)
...
@records = @results.results

# or directly with the collection you need (e.g. records)
@pagy, @records = pagy_searchkik(Model.pagy_search(params[:q]).results, ...)
@pagy, @records = pagy_searchkick(Model.pagy_search(params[:q]).results, ...)
```

### pagy_searchkick_get_vars(array)

This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_searchkik` method. (see the [pagy_get_vars doc](../api/backend.md#pagy_get_varscollection-vars)).
This sub-method is similar to the `pagy_get_vars` sub-method, but it is called only by the `pagy_searchkick` method. (see the [pagy_get_vars doc](../api/backend.md#pagy_get_varscollection-vars)).