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.
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:
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.