你好我在使用will paginate
gem时遇到了问题。我想在我的主播标签下打开所有分页,这是"志愿者"。
分页生成的链接类似于"/project_name?page=2"
但我想在链接中也包含我的锚标签。就像链接应该是"/project_name?page=2#volunteers"
一样。每次用户点击下一页时,如何获得此链接?
在projects_controller.rb
中def show
@volunteers=@volunteers.paginate(:page => params[:page], :per_page => 3 )
end
在show.html.slim
=will_paginate @volunteers
答案 0 :(得分:2)
I got the solution finally that can add an anchor to the links so that the page redirects to the desired tab.In view replace
will_paginate @volunteers
with
will_paginate @volunteers,:container => false,:params => {:anchor => "volunteers"}
这将生成一个新的网址,例如'/ projects?page = 2#volunteers'。