The will_paginate path only works on page> 1

I have defined the following routes:

map.resources :categories, :has_many => :downloads map.resources :downloads, :member => {:go => :get}, :collection => {:tag => :get} map.connect '/downlods/page/:page', :controller => 'downloads', :action => 'index' map.connect '/categories/:category_id/downloads/page/:page', :controller => 'downloads', :action => 'index' 

For some reason, the first page to which the will_paginate helper is called invokes a link renderer with? page = 2, and on the following pages - links from / downloads / page / 2. Do you know what could be the reason for this?

+4
source share
1 answer

If you simply declare a route using map.connect, you can skip it and skip how it is routed if you do something like:

 link_to("Next", :page => 2) 

What you can do is specify a route and then use it this way:

 map.downloads_paginated '/downloads/page/:page', :controller => 'downloads', :action => 'index' 

Then you use the route by name:

 link_to("Next", downloads_paginated_path(2)) 

It is much more reliable.

As a note, you have "/ downlods" in your path instead of "/ downloads", but I'm not sure if this will cause the problem described.

+1
source

Source: https://habr.com/ru/post/1307126/


All Articles