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

Fix a bug for checking JSONAPI::Relationship::ToOne authorization #82

Closed
wants to merge 1 commit into from

Conversation

clemoberti
Copy link

I had an error when I wanted to fetch a relationship and managed to fix it like this.
I'm not sure if that is the most correct way to do it but it worked for me.
Thanks for your efforts!

I had an error when I wanted to fetch a relationship and managed to fix it like this.
I'm not sure if that is the most correct way to do it but it worked for me.
Thanks for your efforts!
@valscion
Copy link
Member

valscion commented Sep 7, 2017

Hi! Thanks for your PR :)

I had an error

Could you clarify a bit? I'd need to know what the exact error was so I could figure out what this code is fixing. Ideally, I'd like to get a spec case to avoid a similar error from happening in the future, so knowing what error this fixes is crucial 😄

@clemoberti
Copy link
Author

clemoberti commented Sep 7, 2017

Yes sure!
So let's say we have two JSONAPI::Resources like this:

module Api::V1
  class UserResource < BaseResource
    has_one :profile
  end
end


module Api::V1
  class ProfileResource < BaseResource
    has_one :user
  end
end

If I try to call the following endpoint:
localhost:3000/api/v1/profiles/XXXXXXXXX/relationships/user
or this one
localhost:3000/api/v1/profiles/XXXXXXXXX/user

I get the following exception:

"exception": "undefined method `user' for #<Api::V1::ProfileResource:0x00000006265ec0>",
                "backtrace": [
                    "/home/clement/.rvm/gems/ruby-2.4.1/bundler/gems/jsonapi-authorization-24bfed7949a3/lib/jsonapi/authorization/authorizing_processor.rb:75:in `public_send'",

I hope my example makes sense? Do not hesitate if you need me to clarify

@valscion
Copy link
Member

valscion commented Sep 7, 2017

Hmm, can you tell me what version of jsonapi-resources you are using? And what version of jsonapi-authorization?

@clemoberti
Copy link
Author

clemoberti commented Sep 7, 2017

I'm on both master branches:

  • jsonapi-resources master@19f4d7b
  • jsonapi-authorization master@24bfed7

@valscion
Copy link
Member

valscion commented Sep 7, 2017

OK, that makes sense. We do not yet support the upcoming jsonapi-resources v0.10 (see #64), so could you try downgrading jsonapi-resources to 0.9.0 and see if your error goes away?

@clemoberti
Copy link
Author

Damn, sorry about that... Yes the errors goes away in the previous version!

@valscion
Copy link
Member

valscion commented Sep 7, 2017

Yess, great to hear that! I'm gonna close this issue, and add a link to #64 to notice that there will be trouble heading down this road :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants