0

我正在使用名为acts_as_followerhttps://github.com/tcocca/acts_as_follower)的 gem

然后我在用户表中有一列last_active_at(用户模型)

在这里,我要获取 current_user 关注的所有用户。
它必须由last_active_at

我试过这个,但它不按顺序。我该如何解决?

控制器

@users = current_user.following_users(order: 'users.last_active_at DESC')
@users_followed = Kaminari.paginate_array(@users)
4

1 回答 1

3

如果您使用的是 Rails 3,则可以使用 arel 接口:

@users = current_user.following_users.order('users.last_active_at DESC')
于 2013-06-12T11:15:01.013 回答