Skip to content

How to reset rule cache ? #283

Closed Answered by palkan
nflorentin asked this question in Q&A
Jan 10, 2025 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Currently, you can achieve this by busting the authorization context like this:

# add additional context value (anything would work) to cache the policy using a non-default key
authorize! project, to: :transfer?, context: {skip_cache: true}

project.transfer(new_user)

allowed_to?(:transfer?, project)

This way, you can separate caching contexts for actions (at all levels, not just rules cache).

You can play with this implementation here: https://runruby.dev/?gist=edddad2f3de94673cae7ca6254910ee7

See also palkan/action_policy-graphql#53

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nflorentin
Comment options

Answer selected by palkan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants