mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Fix caching issue happening with memory_store
It seems that fecthing from memory_store returns a reference to the object and not a copy. Since the Attributes adapter applies #merge! on the Hash that is returned from the memory_store, the value in the cache is also modified.
This commit is contained in:
parent
d50d29b601
commit
fb62fb39b2
@ -55,7 +55,7 @@ module ActiveModelSerializers
|
|||||||
def serializable_hash_for_single_resource(options)
|
def serializable_hash_for_single_resource(options)
|
||||||
resource = resource_object_for(options)
|
resource = resource_object_for(options)
|
||||||
relationships = resource_relationships(options)
|
relationships = resource_relationships(options)
|
||||||
resource.merge!(relationships)
|
resource.merge(relationships)
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_relationships(options)
|
def resource_relationships(options)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module ActiveModelSerializers
|
|||||||
# TODO: figure out why turning on the memory cache changes
|
# TODO: figure out why turning on the memory cache changes
|
||||||
# the result of the CacheTest#test_associations_cache_when_updated
|
# the result of the CacheTest#test_associations_cache_when_updated
|
||||||
# and if it is more correct or less correct.
|
# and if it is more correct or less correct.
|
||||||
# config.action_controller.cache_store = :memory
|
config.action_controller.cache_store = :memory_store
|
||||||
end
|
end
|
||||||
|
|
||||||
app.routes.default_url_options = { host: 'example.com' }
|
app.routes.default_url_options = { host: 'example.com' }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user