-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show all users with a particular badge? #56
Comments
Hi! Try: def users_with_badge_id(badge_id)
sashes_with_badge = BadgesSash.where(badge_id: badge_id).pluck(:sash_id)
User.where(sash_id: sashes_with_badge)
end
users_array = users_with_badge_id(1) Thanks for your feedback. |
You could also add in class Badge
def users
sashes_with_badge = BadgesSash.where(badge_id: id).pluck(:sash_id)
User.where(sash_id: sashes_with_badge)
end
end And then use the syntax you propose: users_array = Badge.find(1).users The reason is not easy to do in merit is that any other resource (not only users) may have reputation information. |
I'll leave the issue open until I either document this in the wiki or README, or make it nicer (hook in Thanks for your feedback! |
Thanks so much! |
Is there a way to list all the users/records that have been awarded a particular badge?
Something like:
Badge.find(2).users
The text was updated successfully, but these errors were encountered: