Search code examples
ruby-on-railswill-paginate

will_paginate and named_routes


I have some problems using will_paginate and named routes.

Here is some code (my site is in Spanish language):

routes.rb

map.animals '/animales/:scope/:id', :controller => :categories, :action => :show

with these routes I generate URLs like:

www.domain.com/animales/mamiferos/perros

but, when pages links are generated I get links like:

www.domain.com/animals/perros?page=2&scope=mamiferos

Why are they like that?


NOTE: I am also using friendly_id.


Solution

  • You need to make sure that there is no matching route before the animals route in the routes.rb file. E.g. the default route map.connect ":controller/:action/:id" and the resource definition map.resources :animals should come after the named animals route.