Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return messages #1

Open
aldesantis opened this issue Oct 12, 2017 · 0 comments
Open

Return messages #1

aldesantis opened this issue Oct 12, 2017 · 0 comments
Labels

Comments

@aldesantis
Copy link
Member

aldesantis commented Oct 12, 2017

I'm not sure how this could work, but it would probably be very useful if allowed users to return an error message when forbidding.

I imagine it could look something like this:

def update?
  return true if user.admin? || resource.author == user
  [false, 'You must be an admin or the author to update an article.']
end

# somewhere else
result, error = policy.update?

The only semantic issue with this proposal is that predicate methods are supposed to return a boolean, while this would make them return true or an array.

@aldesantis aldesantis changed the title Allow returning an optional message with the policy error Forbidden messages Jul 15, 2018
@aldesantis aldesantis changed the title Forbidden messages Return messages Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant