I am using Kaminari to handle pagination. I recently found out that a lot of bogus request is requesting an invalid page number, such as /post/page/undefined
. Since I am using Solr, bad page number got passed into it and cause 500 error.
I want to be able to validate the page number, before it gets passed to the controller. So invalid page number will cause routing error instead.
I have asked the creator of Kaminari, and he gave a temporary solution. However I am wondering if there are cleaner ways to do this. I also don't want to include this logic in every paginable resource, as that will be not DRY at all.
My route example:
resources :transactions do
get 'page/:page', :action => :index, :on => :collection
end