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' 
... 
... 
... 

回答

相關問題