Search code examples
ruby-on-railsmongodbapikaminari

Rails kaminari per_page url


i try to use kaminari gem with my REST API and MongoDB, so far i can use http://127.0.0.1:3000?page=1 to paginate result.

Is there any way to set (per_page attr) from url, like:

http://127.0.0.1:3000?page=1&per_page=10

??


Solution

  • You can use the per scope: see https://github.com/amatsuda/kaminari#query-basics

    The query will be formed as follows:

    @objects.page(params[:page]).per(params[:per_page])