varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.24k stars 627 forks source link

Revert "Merge pull request #625 from holyketzer/custom-messages" #684

Closed Burgestrand closed 3 years ago

Burgestrand commented 3 years ago

Reverting this because it's blocking us from making a new release, see: https://github.com/varvet/pundit/issues/656#issuecomment-895827605

Additionally, me and @dgmstuart have backtracked a bit and believe that in case you'd like to use a solution similar to this then you should probably use specialized error classes instead, something similar to this:

UserProjectLimitReachedError = Class.new(Pundit::NotAuthorizedError)

def create?
  raise UserProjectLimitReachedError unless user.has_paid_subscription?
end

All that said, I believe that the reasoning in https://github.com/varvet/pundit/issues/654 is sound, and so query methods should strive towards returning truthy/falsy as opposed to raising errors to deal with custom error messages.