Skip to content

Call the same policy multiple times #53

@Tao-Galasse

Description

@Tao-Galasse

Hello @palkan ! 👋

First of all, thank you for your amazing gem 💎

Here is my issue: in my mutation, I want to run the same validation multiple times, because my record may have change.

To be more specific, I have a Demand object which has a status. I have an AcceptDemand mutation, which changes the status of the demand to the next one.
But, my users may have several roles, allowing them the accept multiple statuses at a time ; so I wrote something like this :

demand.status = demand.next_status
demand.status = demand.next_status while authorize! demand, to: :accept?

However, I realized we do not re-do the checks ; once the authorize! has been called, it is never called again, and returns the same result than the first time.
The issue is the same with authorize! or allowed_to? methods.

I understand it is probably a cache feature which makes sense in most cases, but could it be possible to force the accept? policy to be run again?

Thanks for your help & have a good day 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions