同じ画面上にpagination機能がある一覧を複数表示させたい場合がよくあります。
そんな時の実装方法です。
実装方法
paginationを表示するview中のpaginateメソッドに:param_nameオプションを付けます。
これによって、paginationに使用するパラメータのkeyを指定出来ます。
<%= paginate @vip_users, :param_name => 'vip_page' %>
<%= paginate @normal_users, :param_name => 'normal_page' %>
あとは、controller上でそれぞれのパラメータを使用するようにします。
@vip_users = User.where(#条件#).page(params[:vip_page]).per(10)
@normal_users = User.where(#条件#).page(params[:normal_page]).per(10)