diff --git a/README.md b/README.md index 0ce97b6..4caf3f0 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,23 @@ Typesense.configuration = { } ``` +### Pagination & Search in a controller with Pagy + +```ruby +class ProductsController < ApplicationController + def index + # If `params[:q]` is blank, Typesense will automatically use "*" to return all documents + @pagy, @products = Product.search(params[:q], "name,description") + end +end +``` + +```erb +

Search results for <%= params[:q] %>

+<%= render @products %> +<%== pagy_nav(@pagy) if @pagy.pages > 1 %> +``` + ## Testing To run the test suite: