<?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>Wed, 18 Jan 2012 16:07:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<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>
	<item>
		<title>By: Rails to_json or as_json? : Mike&#039;s burogu</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-141</link>
		<dc:creator>Rails to_json or as_json? : Mike&#039;s burogu</dc:creator>
		<pubDate>Thu, 29 Sep 2011 18:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-141</guid>
		<description>&lt;p&gt;[...] to Jonathan Julian&#8217;s fantastic post on the subject, here&#8217;s some code that I used today in a project. I set about defining an [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] to Jonathan Julian&#8217;s fantastic post on the subject, here&#8217;s some code that I used today in a project. I set about defining an [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/comment-page-1/#comment-140</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Fri, 23 Sep 2011 18:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanjulian.com/?p=187#comment-140</guid>
		<description>&lt;p&gt;Thanks. saved me.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks. saved me.</p>]]></content:encoded>
	</item>
</channel>
</rss>

