How to reset rule cache ? #283
-
Hi, First of all, thanks for your amazing work, I'm really appreciate action_policy, by far the best gem for authorization ! My little issue is I'm wondering how to reset a rule cached. I seemed to have understand that it takes place here in I browsed the doc with no success and did not find an answer reading the codebase. My use-case is very simple: In step 1, I call In step 3, when I render the view in my server response, I call the same I could use Thanks in advance for your answer ! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I just found out that using |
Beta Was this translation helpful? Give feedback.
-
Hi |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
Currently, you can achieve this by busting the authorization context like this:
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