Skip to content

Commit

Permalink
Fix caching issue happening with memory_store
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Yohan Robert committed Mar 30, 2016
1 parent ea6d171 commit 537fdc2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/active_model_serializers/adapter/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def cached_attributes(cached_serializer)
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)
Expand Down
2 changes: 1 addition & 1 deletion test/support/rails_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down

0 comments on commit 537fdc2

Please sign in to comment.