开发者

Sort users by karma in thumbs_up Rails Gem

开发者 https://www.devze.com 2023-02-27 03:25 出处:网络
Is it possible to sort users by how much karma they have from getting votes on their voteable objects in the thumbs_up Rails gem? If anyone could detail the scope c开发者_运维百科ode required I would

Is it possible to sort users by how much karma they have from getting votes on their voteable objects in the thumbs_up Rails gem? If anyone could detail the scope c开发者_运维百科ode required I would greatly appreciate it.


Easiest way to do this would be to have a column in the users table that stores the total amount of karma points a user has.

Set the default to 0. And then in your karma_controller, you can put a after_save call back that updates the associated user's karma_count field every time that user is rated.

Then all you need to do is User.order("karma_count asc")

That should be enough to point you in the right direction.

0

精彩评论

暂无评论...
验证码 换一张
取 消