-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Prefer object.cache_key when available. #1642
Conversation
I know this is broken, but now it's easier to see what it should be. |
This code was hard to extract and could use a good review. @kevintyll Does this work for you? Also see #1644 |
@@ -161,13 +193,20 @@ def test_fragment_cache_with_inheritance | |||
refute_includes(base.keys, :special_attribute) | |||
end | |||
|
|||
def test_uses_adapter_in_cache_key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is not proving that the adapter is in the cache key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lulz. Thanks! 👍
👍 |
9cb0841
to
e7c3ebc
Compare
This will prevent objects PORO objects that don't have updated_at defined, from throwing an error. Not as big a deal now that PORO objects can inherit ActiveModelSerializers::Model, but still necessary if it's not inherited for whatever reason. Add the Adapter type to the cache key. This prevents incorrect results when the same object is serialized with different adapters. BF: Cherry-pick of 040a97b which was a squash of https://github.com/rails-api/active_model_serializers/commits/f89ed71058322fe7dd35d5c8b209856f8e03ad14 from pr 1346
Does it generates the same cache key for different serializers on the same model ? |
@lambda2 if using object.cache_key, then yes, it will. Please open a new issue with some examples of this |
Continues work in #1346
Fixes #1344
Cherry-pick of
bf4@040a97b
which was a squash of
https://github.com/rails-api/active_model_serializers/commits/f89ed71058322fe7dd35d5c8b209856f8e03ad14