From da3a80dd4fadde9b3bd671c72b5bee737fb70e39 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 26 Apr 2009 15:04:02 -0700 Subject: Track object ids so the objects needn't respond to == --- activesupport/lib/active_support/json/encoding.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 42a217cedc..e8e9308495 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -6,8 +6,8 @@ module ActiveSupport # Converts a Ruby object into a JSON string. def self.encode(value, options = {}) seen = (options[:seen] ||= []) - raise CircularReferenceError, 'object references itself' if seen.include?(value) - seen << value + raise CircularReferenceError, 'object references itself' if seen.include?(value.object_id) + seen << value.object_id value.send(:rails_to_json, options) ensure seen.pop -- cgit v1.2.3