ruby-on-railskaminari

Kaminari Change Max Per Page in Controller


I was wondering if its possible to set the max_per_page value at the controller. I have the default set:

Kaminari.configure do |config|
  config.max_per_page = 100
end

or the max_paginates_per set in the model:

class Test < ActiveRecord::Base
  max_paginates_per 100
end

But in the controller I want a different value... for example, use the default max for the web view, and use a different value for the API routes. Something like:

Test.page(params[:page]).per(params[:per]).max_per_page(500)

Note I don't want the per to be 500... It is configurable by the parameters... I just want its max allowable value to be 500.

Thanks!


Solution

  • Currently this cannot be done, but there is a pull request addressing the issue: https://github.com/amatsuda/kaminari/pull/736