Will_paginate插件在同一页面上的两个对象上 [英] Will_paginate Plugin on two objects on same page

查看:83
本文介绍了Will_paginate插件在同一页面上的两个对象上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在同一页面上的两个对象上使用will_paginte插件.就像在stackoverflow上一样.有一个个人资料页面,其中有关于两件事的分页 问题和答案.

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.

我有问题,即:- 当用户单击问题分页时2.答案页也在更新.原因是两者都发送了post变量,即

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.

他位于问题的第三页和答案的第一页,现在他单击问题的第五页,结果应该是问题的第三页和答案的第五页.

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.

推荐答案

您可以指定:param_name选项,告诉will_paginate URL中用于页码的参数名称(默认为:page).因此,您可以这样做:

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文档
    • will_paginate documentation
    • 这篇关于Will_paginate插件在同一页面上的两个对象上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆