I'm trying to replace ?page= with /page/2 for all paginated pages in my Rails 6 application, so that I can be able to use Page Caching according to this guide.
I'm using the Pagy gem for pagination and according to their documentation, I should be able to add a helper method to override to add support for fancy routes.
I've added this block to my application_helper.rb
def pagy_url_for(pagy, page)
params = request.query_parameters.merge(pagy.vars[:page_param] => page )
url_for(params)
end
However, after I do that I get this error:
"undefined method `vars' for "__pagy_page__":String"
Any ideas on how to solve that?