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
{{ message }}
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
Calling .to_json on a GlobalPhone::Number throws a CircularReferenceError. This is in Rails v4.0.5 with Ruby v.1.9.3.
1.9.3-p547 :001 > number = GlobalPhone.parse("6541238888")
=> #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="6541238888">
1.9.3-p547 :002 > number.to_json
ActiveSupport::JSON::Encoding::CircularReferenceError: object references itself
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:79:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:ineach'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inencode_json'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:inmap'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:inblock in encode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:ineach'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inencode_json'
... 9 levels...
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inblock in encode_json'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in each' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inmap'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:inblock in encode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:34:in encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/core_ext/object/to_json.rb:16:into_json'
from (irb):2
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:90:in start' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:9:instart'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands.rb:62:in <top (required)>' from bin/rails:4:inrequire'
from bin/rails:4:in `
'1.9.3-p547
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Calling .to_json on a GlobalPhone::Number throws a CircularReferenceError. This is in Rails v4.0.5 with Ruby v.1.9.3.
1.9.3-p547 :001 > number = GlobalPhone.parse("6541238888")
'1.9.3-p547=> #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="6541238888">
1.9.3-p547 :002 > number.to_json
ActiveSupport::JSON::Encoding::CircularReferenceError: object references itself
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:79:in
check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in
encode'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
each'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
encode_json'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in
block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in
map'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in
encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:in
block in encode'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in
check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in
encode'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
each'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
encode_json'... 9 levels...
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in
encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
block in encode_json'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
each' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
map'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in
encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:in
block in encode'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in
check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in
encode'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:34:in
encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/core_ext/object/to_json.rb:16:in
to_json'from (irb):2
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:90:in
start' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:9:in
start'from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands.rb:62:in
<top (required)>' from bin/rails:4:in
require'from bin/rails:4:in `
The text was updated successfully, but these errors were encountered: