title: rails to_json unexpected behavior for include_root_in_json
body: <p>I have a model like this</p>
  
  <pre><code>class Parent &lt; ActiveRecord::Base
    :has_many :kids
  end
  
  class Kid &lt; ActiveRecord::Base
    :has_many :grandkids
    :belongs_to :parent
  end
  </code></pre>
  
  <p>I can generate json like this:</p>
  
  <pre><code>the_parent.to_json( :methods =&gt; [:kids] )
  </code></pre>
  
  <p>=> <strong>{ "parent" : { "kids" : [ { "kid" : { "name" => "kid0"</strong> .... and so on.  Just what I want.  Each object looks like a hash with a single key - which is the model name - and the value is an attribute hash.  Great.</p>
  
  <p>But I get into trouble when I try to serialize the whole tree, like this:</p>
  
  <pre><code>the_parent.to_json( :include =&gt; { :kids =&gt; { :include =&gt; :grandkids } } )
  </code></pre>
  
  <p>=> <strong>{ "parent" : { "kids" : [ { "name" => "kid0"</strong> ...
  which is missing the model names in the "kids" array.  The same thing happens at the next level with the grandkids.  I'm going to parse this somewhere else, and it would help to have certainty about the object name (as opposed to relying on convention using the relationship name).  The docs advertise this:</p>
  
  <pre><code>ActiveRecord::Base.include_root_in_json = true
  </code></pre>
  
  <p>Which I found it to have no effect.  My guess is the different behavior has something to do with the difference between the :method and :include options, but I can't wrangle the :method syntax to get the nesting I need, and I'm not sure if that will work even if it compiles.</p>
  
  <p>Any ideas?  Thanks, Dan</p>