可以将 paginate 与 Acts_as_follower 一起使用吗? [英] Is that possible to use paginate with Acts_as_follower?

查看:43
本文介绍了可以将 paginate 与 Acts_as_follower 一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@users = User.find_by_username(params[:username]).all_following.order("created_at DESC").paginate(page: params[:page])

这个计算不起作用:(
我想对acts_as_follower 使用分页和顺序排序.

This calculation won't work:(
I'd like to use pagination and order sort with acts_as_follower.

推荐答案

您可以将订单(以及ActiveRecord#all 接受的任何其他选项)直接传递给 all_following like这个

You can pass the order (and any other option ActiveRecord#all accepts) directly to all_following like this

@users = User.find_by_username(params[:username]).all_following(:order => 'created_at DESC').paginate(page: params[:page])

更新:will_paginate 可以对数组进行分页,但您必须告诉 Rails 包含这部分,因为它默认不包含,请检查此 答案.

UPDATE: will_paginate can paginate an array but you have to tell Rails to include this part as it's not included by default, please check this answer.

这篇关于可以将 paginate 与 Acts_as_follower 一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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