<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Rails to_json or as_json?</title>
	<atom:link href="http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/</link>
	<description>Ruby, Rails, JavaScript, software development</description>
	<lastBuildDate>Fri, 04 May 2012 17:52:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Rafael Revi</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-167</link>
		<dc:creator>Rafael Revi</dc:creator>
		<pubDate>Fri, 04 May 2012 17:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-167</guid>
		<description>&lt;p&gt;Great post jjulian!&lt;/p&gt;

&lt;p&gt;any chance you can help with http://stackoverflow.com/questions/10433194/rails-format-json&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Great post jjulian!</p>

<p>any chance you can help with http://stackoverflow.com/questions/10433194/rails-format-json</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnemg</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-163</link>
		<dc:creator>Magnemg</dc:creator>
		<pubDate>Wed, 07 Mar 2012 12:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-163</guid>
		<description>&lt;p&gt;So helpful! thanks. Didn&#039;t know about as_json before.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>So helpful! thanks. Didn&#8217;t know about as_json before.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pseudo_rails</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-150</link>
		<dc:creator>pseudo_rails</dc:creator>
		<pubDate>Wed, 14 Dec 2011 10:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-150</guid>
		<description>&lt;p&gt;Oops, I had a typo in my MyController pseudo code.  &lt;/p&gt;

&lt;p&gt;It should be this:&lt;/p&gt;

&lt;p&gt;class MyController &lt; ApplicationControllerrespond_to :jsondef show@user = User.find(params[:id])
 respond_with(@user , :include =&gt; {:addresses =&gt; {:include =&gt; :email}})
end&lt;/p&gt;

&lt;p&gt;Which I want to refactor with something like this in the model:
def as_json(options={})super(:only =&gt; [:email, :avatar], :include =&gt;[:addresses =&gt; {:include =&gt; :email}])end&lt;/p&gt;

&lt;p&gt;But I get an 
undefined method `macro&#039; for nil:NilClass&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Oops, I had a typo in my MyController pseudo code.  </p>

<p>It should be this:</p>

<p>class MyController &lt; ApplicationControllerrespond_to :jsondef show@user = User.find(params[:id])
 respond_with(@user , :include =&gt; {:addresses =&gt; {:include =&gt; :email}})
end</p>

<p>Which I want to refactor with something like this in the model:
def as_json(options={})super(:only =&gt; [:email, :avatar], :include =&gt;[:addresses =&gt; {:include =&gt; :email}])end</p>

<p>But I get an 
undefined method `macro&#8217; for nil:NilClass</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pseudo_rails</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-149</link>
		<dc:creator>pseudo_rails</dc:creator>
		<pubDate>Wed, 14 Dec 2011 10:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-149</guid>
		<description>&lt;p&gt;Given the following example from your blog post:&lt;/p&gt;

&lt;p&gt;def as_json(options={})
  super(:only =&gt; [:email, :avatar], :include =&gt;[:addresses])
end&lt;/p&gt;

&lt;p&gt;when overriding the as_json method, if I want to include nested child nodes, how would I go about doing so?  I essentially want to refactor the respond_with usage in my controller by just overriding the as_json method in the model.&lt;/p&gt;

&lt;p&gt;class  MyController &lt; ApplicationController
respond_to :json
def show
    @user = User.find(params[:id])
    respond_with(@tag, :include =&gt; {:addresses =&gt; {:include =&gt; :email}})
end&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Given the following example from your blog post:</p>

<p>def as_json(options={})
  super(:only =&gt; [:email, :avatar], :include =&gt;[:addresses])
end</p>

<p>when overriding the as_json method, if I want to include nested child nodes, how would I go about doing so?  I essentially want to refactor the respond_with usage in my controller by just overriding the as_json method in the model.</p>

<p>class  MyController &lt; ApplicationController
respond_to :json
def show
    @user = User.find(params[:id])
    respond_with(@tag, :include =&gt; {:addresses =&gt; {:include =&gt; :email}})
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-148</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 25 Nov 2011 21:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-148</guid>
		<description>&lt;p&gt;very helpful post, thanks &lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>very helpful post, thanks </p>
]]></content:encoded>
	</item>
</channel>
</rss>

