0
如何在Rolify中查找特定资源实例的所有角色?该documentation提出以下建议:在Rolify中查找特定资源实例的所有角色
Forum.find_roles
# => [ list of roles that binded to any Forum instance or to the Forum class ]
但是,如果我需要一个特定的Forum
实例是什么? Forum.first.find_roles
不起作用。有另一种方法吗?这就是我试图用Location
代替Forum
:
2.1.5 :003 > Location.first.find_roles
Location Load (0.3ms) SELECT "locations".* FROM "locations" ORDER BY "locations"."id" ASC LIMIT 1
NoMethodError: undefined method `find_roles' for #<Location:0x007fbe880d1b48>
from /Users/scott/.rvm/gems/[email protected]/gems/activemodel-4.2.1/lib/active_model/attribute_methods.rb:433:in `method_missing'
...
...
...
正是我在找的,谢谢。 – 2015-04-01 00:35:37