Permalink
Browse files

Track object ids so the objects needn't respond to ==

  • Loading branch information...
1 parent dc2caea commit da3a80dd4fadde9b3bd671c72b5bee737fb70e39 @jeremy jeremy committed Apr 26, 2009
Showing with 2 additions and 2 deletions.
  1. +2 −2 activesupport/lib/active_support/json/encoding.rb
@@ -6,8 +6,8 @@ class CircularReferenceError < StandardError
# 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

0 comments on commit da3a80d

Please sign in to comment.