Search code examples
ruby-on-railspaginationkaminari

Problem with nested resources with Kaminari pagination gem


Can't seem to get Kaminari to work properly with nested resources. Here is a description of my problem. Wondering if anybody was able to tackle this issue.

My routes look like:

resources :artists do
  resources :paintings
end

In my view, I have:

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

The initial / base url looks like this:

http://localhost/artists/foobar/paintings

But clicking on a kaminari paginate link, renders the url like this:

http://localhost/paintings?artist_id=foobar&page=2

It's supposed to be:

http://localhost/artists/foobar/paintings?page=2

Solution

  • Ooops. Just realised, apparently a route was being prioritized....

    Seems to work now...