Skip to content

Commit c7e847f

Browse files
LongCBbf4
authored andcommitted
Fix thread unsafe behavior
1 parent 127b04b commit c7e847f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/active_model/serializer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def associations(include_directive = ActiveModelSerializers.default_include_dire
347347
return Enumerator.new {} unless object
348348

349349
Enumerator.new do |y|
350-
self.class._reflections.each do |key, reflection|
350+
(@reflections ||= self.class._reflections.deep_dup).each do |key, reflection|
351351
next if reflection.excluded?(self)
352352
next unless include_directive.key?(key)
353353

@@ -411,6 +411,6 @@ def associations_hash(adapter_options, options, adapter_instance)
411411

412412
protected
413413

414-
attr_accessor :instance_options
414+
attr_accessor :instance_options, :reflections
415415
end
416416
end

0 commit comments

Comments
 (0)