Simple patch really, that adds :include option to ActiveRecord::Base#to_json like for ActiveRecord::Base#to_xml:
http://dev.rubyonrails.org/ticket/9677
Allows you to do:
json = @david.to_json(:include => :posts) # or even... json = @david.to_json( :include => { :posts => { :include => { :taggings => { :include => { :tag => { :only => :name } } } } } })
Please use the 2nd diff (http://dev.rubyonrails.org/attachment/ticket/ 9677/add_includes_to_to_json.2.diff) - I forgot to replace the existing diff when uploading a small fix.
Thanks!
Cheers, Chu Yeow