开发者

will_paginate route only works on page > 1

I have the following routes defined:

map.resources :categories, :has_many => :downloads
map.resources :downloads, :member => {:go开发者_如何学JAVA => :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 that the will_paginate helper is called on causes links with ?page=2 to be rendered, while subsequent pages have links with /downloads/page/2. Do you know what might be causing this?


If you simply declare a route with map.connect, it can be hit and miss as to how it's routed if you do something like:

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

What you might want to do is name the route and then use it that 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))

These are much more reliable.

As a note, you have '/downlods' in your path instead of '/downloads' but I'm not sure that'd be causing the trouble described.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜