Last active
August 29, 2015 14:01
-
-
Save msavy/884642ff7a8b835a4d9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'activesupport/json_encoder' | |
class A | |
def initialize; @thing = "zoidberg"; end | |
def as_json(options={}) | |
{ | |
:whynot => @thing, | |
:this => "string" | |
} | |
end | |
end | |
class B | |
def initialize; @obja = A.new; end | |
def as_json(options={}) | |
{ | |
:obja => @obja | |
} | |
end | |
end | |
# Works | |
puts B.new.to_json | |
# Doesn't work | |
puts JSON.pretty_generate(B.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment