will_paginate 路由仅适用于页面 > 1
我定义了以下路由:
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'
出于某种原因,调用 will_paginate 帮助程序的第一个页面会导致呈现带有 ?page=2 的链接,而后续页面则具有带有 /downloads/page/2 的链接。你知道这可能是什么原因造成的吗?
I have the following routes defined:
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是使用 map.connect 声明一条路线,那么如果您执行以下操作,则它的路由方式可能会出现问题:
您可能想要做的是命名该路线,然后以这种方式使用它:
然后您使用该路线按名称:
这些更可靠。
请注意,您的路径中有“/downloads”而不是“/downloads”,但我不确定这会导致所描述的问题。
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:
What you might want to do is name the route and then use it that way:
Then you use the route by name:
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.