mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
move @node assignment and the include_associations! call outside the cached response, since including associations produces the side-effect *actually* including the associations.
Previously, subsequent renders of a cached serializer would never include associations.
This commit is contained in:
parent
1a684927c4
commit
ab502f0c52
@ -353,13 +353,16 @@ module ActiveModel
|
||||
# Returns a hash representation of the serializable
|
||||
# object without the root.
|
||||
def serializable_hash
|
||||
if perform_caching?
|
||||
@node = if perform_caching?
|
||||
cache.fetch expand_cache_key([self.class.to_s.underscore, cache_key, 'serializable-hash']) do
|
||||
_serializable_hash
|
||||
end
|
||||
else
|
||||
_serializable_hash
|
||||
end
|
||||
|
||||
include_associations! if _embed
|
||||
@node
|
||||
end
|
||||
|
||||
def include_associations!
|
||||
@ -476,9 +479,7 @@ module ActiveModel
|
||||
|
||||
def _serializable_hash
|
||||
return nil if @object.nil?
|
||||
@node = attributes
|
||||
include_associations! if _embed
|
||||
@node
|
||||
attributes
|
||||
end
|
||||
|
||||
def perform_caching?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user