biola/humanity — pull request #2 by thec0keman (2014-01-01 19:05:11+00:00)
Title: Added human_names to Role

I have a couple of situations where I need to get a list of all of the users for a specific role. I was using this:

role_id = Humanity::Role.find_by(name: role.to_sym).try(:id)
self.joins(:assignments).where(assignments: { role_id: role_id })

But this is rather ugly and I think something like the patch below would help.

I'm not sure if this is the best way to handle the polymorphic relationship though. One downside is it doesn't eager load, but at least for my situation this is only a half dozen or so db calls