Find all users with specific role using rolify

roman picture roman · Jul 5, 2012 · Viewed 9.7k times · Source

How can i get all users with specific role when using rolify? I've tried the following but it didn't help:

User.with_role :admin

I get the following error:

NoMethodError: undefined method `with_role' for #<Class:0x0000000743f9c0>

Couldn't find any way to do this.

Answer

Lookchin picture Lookchin · Dec 12, 2012

You can use the with_role method with a User class to find all users who has a role in version 3.1.0.

User.with_role :admin