-2

向使用 Cancan 和 Rolify gem 了解 Rails 的人提出的问题。我想了解如何获取具有某些角色(例如,公司)的用户列表。

这是带有代码的描述和详细描述:

https://github.com/EppO/rolify/issues/260

感谢您的任何想法!

弗拉基米尔

4

1 回答 1

0

According to the documentation you have to use

@users = User.with_all_roles(:owner, :client, :manager, @company)

instead of

@users = User.with_role([:owner, :client, :manager], @company)

Or if you can get all the users who has at least one of the roles: has_any_role

See more: https://github.com/EppO/rolify/wiki/Usage#finders-methods

于 2014-05-30T18:02:32.617 回答