如何在一个视图中分页两个表

时间:2021-06-25 12:17:26

I want to ask if i can use will_paginate plugin two times on one page? For example i have table with male users and table with female users on one page or in one view and I need paginate both tables. My question is what is the usual solution of this problem?

我想问我是否可以在一个页面上使用两次will_paginate插件?例如,我在一个页面或一个视图中有男性用户的表和女性用户的表,我需要对两个表进行分页。我的问题是这个问题通常的解决办法是什么?


1 个解决方案

#1


6  

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:

您可以指定一个:param_name选项,告诉will_paginate url中的参数名称,用于url中的页码(默认值是:page)。所以你可以做的:

<%= will_paginate @males,   :param_name => 'males_page' %>
<%= will_paginate @females, :param_name => 'females_page' %>

#1


6  

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:

您可以指定一个:param_name选项,告诉will_paginate url中的参数名称,用于url中的页码(默认值是:page)。所以你可以做的:

<%= will_paginate @males,   :param_name => 'males_page' %>
<%= will_paginate @females, :param_name => 'females_page' %>