Skip to content

Don't cache resource classes based on model class#773

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
alyssais:resources_for
Jul 21, 2016
Merged

Don't cache resource classes based on model class#773
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
alyssais:resources_for

Conversation

@alyssais
Copy link
Copy Markdown

resource_for_model passes the model instance, so resources can vary based on model instance.
Caching them based on model class, therefore, can wrongly use a resource that for a record that should use a different resource.

I just ran into this when choosing resource based on the type of a polymorphic relationship.

resource_for_model passes the model instance, so resources can vary
based on model instance. Therefore, caching based on the model class can
cause incorrect resources to be used.
@lgebhardt lgebhardt merged commit a5fef38 into JSONAPI-Resources:master Jul 21, 2016
@lgebhardt
Copy link
Copy Markdown
Contributor

@penman Thanks!

@alyssais alyssais deleted the resources_for branch July 21, 2016 15:55
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