3

I'm having a problem with kaminari, it doesn't seem to be able to paginate results when using a custom "unRestful" url.

resources :provinces, :path => '', :only => [ :show ] do
  resources :sports, :only => [ :show ] do
    match ':page', :controller => 'facilities', :action => 'index'
  end
end

So, /:foo/sports/:bar points to a controller, /:foo/sports/:bar/1 points to another 1. It's a disgusting URL scheme but I don't have the leverage right now to change the specs.

If I call the page without Kaminari, everything works as expected, I see the first page. When I use Kaminari like:

<%= paginate @facilities, :params => { :controller => 'facilities', :action => 'index' } %>

Rails gives me a routing error on the following URL:

http://lvh.me:8080/milano/sports/palestra/1

No route matches {:controller=>"facilities", :province_id=>"milano", :sport_id=>"palestra", :page=>nil}

I honestly don't know what to do, everything seems right to me, and couldn't find a kaminari group or more documentation on my case.

The problem seems to be that the call to paginate somewhat generates a URL with page set to nil...

Any suggestion?

Using rails (3.2.8) Using kaminari (0.14.0)

ngw
  • 1,222
  • 1
  • 14
  • 34
  • Could you try page as query parameter, to debug into more details. This problem does not seems to be with kaminari but rails – ducktyped Feb 17 '14 at 17:01

1 Answers1

0

in controller

 @facilities = kaminari.paginate_array(@facilities).page(params[:page]).per(params[:per_page])

and in your view <%= page_entries_info @facilities %> & <%= paginate @facilities %>

Antony Mithun
  • 161
  • 1
  • 15