Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix caching for namespaced polymorphic associations#1080

Closed
alachaum wants to merge 1 commit into
JSONAPI-Resources:masterJSONAPI-Resources/jsonapi-resources:masterfrom
alachaum:fix-caching-namespaced-resalachaum/jsonapi-resources:fix-caching-namespaced-resCopy head branch name to clipboard
Closed

Fix caching for namespaced polymorphic associations#1080
alachaum wants to merge 1 commit into
JSONAPI-Resources:masterJSONAPI-Resources/jsonapi-resources:masterfrom
alachaum:fix-caching-namespaced-resalachaum/jsonapi-resources:fix-caching-namespaced-resCopy head branch name to clipboard

Conversation

@alachaum

@alachaum alachaum commented Jul 1, 2017

Copy link
Copy Markdown

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
Copy Markdown
Contributor

@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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.