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 caching for namespaced polymorphic associations #1080

Closed

Conversation

alachaum
Copy link

@alachaum alachaum commented Jul 1, 2017

Hi guys,

I noticed there was an issue with caching when looking up namespaced resource classes for polymorphic associations. This issue prevents include queries on resources having a polymorphic association.

Something like this:

class Api::V1::PictureResource < JSONAPI::Resource
  caching
  has_one :imageable, polymorphic: true
end

class Api::V1::ProductResource < JSONAPI::Resource
  has_one :picture
end

..will fail when doing:

# Fails because JR attempts to lookup PictureResource when compiling cached fragments
GET /api/v1/pictures?include=imageable

The test attached to this PR does not create a 500 if the patch is not applied (because both PictureResource and Api::V1::PictureResource are defined) but clearly show that the links are incorrect when caching is enabled.

@lgebhardt
Copy link
Member

@alachaum I think this has been fixed with the rework that has happened in #1045. Please check it out and reopen this if it's still a problem. We'll need to fix it another way since the to_real_resource method no longer exists.

@lgebhardt lgebhardt closed this Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants