chris
chris

Reputation: 39

Sort users by karma in thumbs_up Rails Gem

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 code required I would greatly appreciate it.

Upvotes: 1

Views: 365

Answers (1)

illogikal
illogikal

Reputation: 158

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.

Upvotes: 1

Related Questions