Skip to content

Rolify has_role / has_any_role with multiple resources #182

@burmjohn

Description

@burmjohn

Hoping someone can help me shed some light on how to accomplish this, I'm more then likely looking at this all wrong. Any suggestions / help appreciated.

Works if you just specify one single record as the resource

if user.has_role? :company_admin,  Company.first
...
end

How can you specify multiple resource id's? Example Company 1, Company 2, Company 3?

i.e.

if user.has_role? :company_admin,  Company.all
...
end

I was actually trying to do this:

if user.has_role? :company_user, Company.with_role(:company_user, user)
can :manage, Derp
...
end

Then I found has_any_role?, however I can't find any solid examples on how I could pass Company.all or using my example above Company.with_role(:company_user, user) to it.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions