0

How do I find all roles for a particular resource instance in Rolify? The documentation suggests the following:

Forum.find_roles
# => [ list of roles that binded to any Forum instance or to the Forum class ]

But what if I want a particular Forum instance? Forum.first.find_roles does not work. Is there another way? This is what I tried with Location instead of 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/ruby-2.1.5@rails4/gems/activemodel-4.2.1/lib/active_model/attribute_methods.rb:433:in `method_missing'
...
...
...
4

1 回答 1

0

Location.first.roles应该管用。

参考:https ://github.com/RolifyCommunity/rolify#instance-level

于 2015-03-31T23:01:10.367 回答