thesis
thesis

Reputation: 2575

Kaminari and page routing

I am using kaminari pagination on custom page but it generates /assets based url:

http://localhost:3000/assets?action=my&controller=blogs&page=2

I need:

http://localhost:3000/blogs/my?page=2

Error:

No route matches [GET] "/assets"

Any suggestions?

Upvotes: 2

Views: 3120

Answers (2)

Grant Chen
Grant Chen

Reputation: 375

I have resolved by add controller params.

<%= paginate @blog , :params => {:controller => "GoogleUsers"} %> 

Upvotes: 1

simonb83
simonb83

Reputation: 108

I was having exactly the same problem trying to set-up pagination with either Kaminari or Will_paginate for a custom action. It turned out that the problem was in my routes.rb file.

As an example, my custom action is called 'all_credit' in the 'cards' controller. Previously in routes.rb I had:

match '/cards_credit' => 'Cards#all_credit'

This was giving me the same behaviour you describe above and generating assets/ based urls.

By changing the line in routes.rb to:

match '/cards_credit(/:page)', :controller => 'cards', :action => 'all_credit'

I was able to solve this and the paginated links are now being generated correctly.

Upvotes: 3

Related Questions