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:
Yohan Robert 2016-03-30 11:10:36 +02:00 committed by Benjamin Fleischer
parent d50d29b601
commit fb62fb39b2
2 changed files with 2 additions and 2 deletions

View File

@ -55,7 +55,7 @@ module ActiveModelSerializers
def serializable_hash_for_single_resource(options)
resource = resource_object_for(options)
relationships = resource_relationships(options)
resource.merge!(relationships)
resource.merge(relationships)
end
def resource_relationships(options)

View File

@ -8,7 +8,7 @@ module ActiveModelSerializers
# TODO: figure out why turning on the memory cache changes
# the result of the CacheTest#test_associations_cache_when_updated
# and if it is more correct or less correct.
# config.action_controller.cache_store = :memory
config.action_controller.cache_store = :memory_store
end
app.routes.default_url_options = { host: 'example.com' }