Closed Zhao-Andy closed 5 years ago
@Zhao-Andy I'm having the same issue. I'm using version 5.1.0
Yep, I'm also seeing this. cc @wldcordeiro
@AncyentMariner @dkniffin Seems like the actual method is Model.with_any_role
or Model.with_all_roles
, depending on your use case. I ended up using with_any_role
for mine.
There is a singular version Model.with_role
, which works for checking for one role. For example: User.with_role(:admin)
I found a more accurate documentation in the Usage wiki.
Nice. To finish up this issue then, we'd just need to update the Readme. Maybe just linking to the usage docs would be sufficient.
This is actually confusing, let me clarify.
README.md mentions
Forum.with_roles([:admin, :user], current_user)
# => [ list of Forum instances that have role "admin" or "user" bound to them and belong to current_user roles ]
Forum
is a resource model and contains resourcify
. (3.2 Configure your resource models)
The resourcify
call automatically includes the Resource
module which contains with_roles
as an alias to with_role
.
The aforementioned Usage Wiki is a good finding because it contains two separate sections – Finders
methods (1) and Resource
methods (2).
Indeed, you can call .with_role
(or with_roles
which is an alias) on a model that includes Resource
module. I confess README can be improved to make it clearer
Indeed, you can call
.with_role
(orwith_roles
which is an alias) on a model that includesResource
module. I confess README can be improved to make it clearer
@EppO
Hey its absolutely can't be an aliases, because the generated query is completely wrong from the general conventions.
.with_role
should be receiving a single role as parameter
.with_roles
should be receiving a plural role as parameter
and the generated query have to adjust those different kind of logic.
Doesn't seem like there's an actual method
.with_roles
, even though the ReadMe has it. Is this a deprecated method?