Best way to do multiple reasons #144
tomdalling
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Hey!
Yes and no. Action Policy assumes fail-fast rules execution, thus, in case of What you can do?
def create?
check?(:post_allows_comments?) & check?(:user_not_banned?)
end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @palkan and co,
We're looking at using ActionPolicy reasons, and I was wondering if there is any convention or best practice around generating multiple reasons instead of a single one.
A typical policy might look like this:
Which would give a single failure reason.
But I noticed that if I run multiple checks.
Then I get multiple reasons.
I was thinking of making something like a
check_all?
method as a standard way to do this.Are multiple reasons an intended use case of ActionPolicy that I can rely on? I couldn't see an example of it in the docs. Can you think of any better way to do this?
Beta Was this translation helpful? Give feedback.
All reactions