2013-06-12 160 views
0

我使用所謂的acts_as_followerhttps://github.com/tcocca/acts_as_follower)寶石爲什麼不這樣做?

然後我在用戶表稱爲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) 

回答

3

如果您使用Rails 3,您可以使用AREL接口:

@users = current_user.following_users.order('users.last_active_at DESC') 
+0

謝謝!這就是完美的答案 – MKK

+0

請等待8分鐘,以便我將您的答案作爲最佳答案 – MKK

相關問題