diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index c267e5f0f..ee43f4ba9 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -29,8 +29,8 @@ def self.inherited(base) base._attributes = self._attributes.try(:dup) || [] base._attributes_keys = self._attributes_keys.try(:dup) || {} base._urls = [] - serializer_file = File.open(caller.first[/^[^:]+/]) - base._cache_digest = Digest::MD5.hexdigest(serializer_file.read) + serializer_file_path = caller.first[/\A\S+(?=:\d+:in)/] + base._cache_digest = Digest::MD5.hexdigest(File.read(serializer_file_path)) super end