You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use Pundit scopes and I am unable to get jsonapi-authorization to return a 404 when the user does not have a record.
Am I doing something wrong? I've tried changing the code to have the scope return scope.where(owner: user) without the #all call, but that still does not work.
This was a user error. It would be great for this gem to have a wiki entry on how to handle pundit scopes. For example if I want to scope lookups to current_user and return a 404 (like described in #76)
Long version
It appears the issue was with JSONAPI::Resources and customizing find_by_key. Removing that made things work. Side note, this was the advised approach from the JR wiki
Oh so due to your customization, a nil record was passed into the authorization code and then we tried to find a policy class for that nil?
That sounds like something that is nasty to debug. We could add a friendlier error in case that happens. Would you be open to create a PR to error in a friendly way if a nil record gets passed in to the authorizer class?
valscion
changed the title
Using Pundit scopes breaks show authorization when Not Found
Add a friendly error when Authorizer class is called with a nil record
Jan 24, 2018
I am trying to use Pundit scopes and I am unable to get jsonapi-authorization to return a 404 when the user does not have a record.
Am I doing something wrong? I've tried changing the code to have the scope return
scope.where(owner: user)
without the#all
call, but that still does not work.Example Code
Stacktrace
The text was updated successfully, but these errors were encountered: