Will_paginate Plugin on two objects on same page

爷,独闯天下 提交于 2019-11-29 02:34:52

问题


Hello I am using will_paginte plugin on two objects on a same page. Like on stackoverflow. There is a profile page on which there is a pagination on two things QUestions and answers.

I am having problem ie:-- when user is clicking on questions pagination page 2. answers page are also updating. The reason is both is sending a post variable ie

  params[:page]

How to change this variable so that only one should be updated. and how to maintain that user should not lose the other page.

ie

he is on 3rd page of questions and 1st page of answers and now he click on 5th page of the questions the result should be 3rd page of questions and 5th page of answers.


回答1:


You can specify a :param_name option to tell will_paginate the name of the parameter to use for the page number within URLs (the default is :page). So you could do:

<%= will_paginate @questions, :param_name => 'questions_page' %>
<%= will_paginate @answers, :param_name => 'answers_page' %>
  • will_paginate documentation


来源:https://stackoverflow.com/questions/3069064/will-paginate-plugin-on-two-objects-on-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!