You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the fragment cache's call to attribute (line 52) will continually add field1, such that if resources has 20 objects, by the end, field1 will be called 20 times for the last invocation of the TestSerializer.
I believe ActiveModel::Serializer.attribute should only concat the key onto @_attributes if it is not already present.
i.e., line 45 (in master) should be:
Nice catch! It was indeed a bug which would also happen simply by calling multiple times .attributes or .attribute with the same attribute name. I don't know if this has any consequence on the behavior itself, but it might slow the overall system since we iterate over the @_attributes variable when calling #attributes.
If you define a serializer with a fragment cache, such as
and then render in your controller, an array:
the fragment cache's call to attribute (line 52) will continually add field1, such that if resources has 20 objects, by the end, field1 will be called 20 times for the last invocation of the TestSerializer.
I believe ActiveModel::Serializer.attribute should only concat the key onto @_attributes if it is not already present.
i.e., line 45 (in master) should be:
Also, since the @_attributes variable is at the class level, subsequent requests compound the issue even further.
The text was updated successfully, but these errors were encountered: