<?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: DRYing up Rails Controllers: Polymorphic and Super Controllers</title>
	<atom:link href="http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:36:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: telefon dinleme</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8452</link>
		<dc:creator>telefon dinleme</dc:creator>
		<pubDate>Sun, 09 Aug 2009 00:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8452</guid>
		<description>thank you for your article. i find it after to 1 month... good evening..</description>
		<content:encoded><![CDATA[<p>thank you for your article. i find it after to 1 month&#8230; good evening..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swards</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8451</link>
		<dc:creator>Swards</dc:creator>
		<pubDate>Sun, 28 Jun 2009 21:54:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8451</guid>
		<description>Great - All the ERB was removed.  I&#039;ll do a larger write up and post elsewhere - I&#039;ll link back.</description>
		<content:encoded><![CDATA[<p>Great &#8211; All the ERB was removed.  I&#8217;ll do a larger write up and post elsewhere &#8211; I&#8217;ll link back.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swards</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8450</link>
		<dc:creator>Swards</dc:creator>
		<pubDate>Sun, 28 Jun 2009 21:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8450</guid>
		<description>There&#039;s a simpler way. If you make the comment form a partial and do this instead:




  etc...


(Note the [@commentable, @comment])

 &#039;comment_form&#039;, :locals =&gt; { :commentable =&gt; @user} %&gt;

You don&#039;t need to deal with @klass, constantize, etc.

And, in the comments controller, do something like this:

def create
  @comment = Comment.new(params[:comment])
  @commentable = @comment.commentable
  @comment.save
  ...
end</description>
		<content:encoded><![CDATA[<p>There&#8217;s a simpler way. If you make the comment form a partial and do this instead:</p>
<p>  etc&#8230;</p>
<p>(Note the [@commentable, @comment])</p>
<p> &#8216;comment_form&#8217;, :locals =&gt; { :commentable =&gt; @user} %&gt;</p>
<p>You don&#8217;t need to deal with @klass, constantize, etc.</p>
<p>And, in the comments controller, do something like this:</p>
<p>def create<br />
  @comment = Comment.new(params[:comment])<br />
  @commentable = @comment.commentable<br />
  @comment.save<br />
  &#8230;<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-05-18 &#124; NeXt</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8449</link>
		<dc:creator>links for 2009-05-18 &#124; NeXt</dc:creator>
		<pubDate>Wed, 17 Jun 2009 19:01:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8449</guid>
		<description>[...] Agile Ajax » DRYing up Rails Controllers: Polymorphic and Super Controllers » Pathfinder Developme... (tags: programming tutorial patterns agile controller ruby rails) [...]</description>
		<content:encoded><![CDATA[<p>[...] Agile Ajax » DRYing up Rails Controllers: Polymorphic and Super Controllers » Pathfinder Developme&#8230; (tags: programming tutorial patterns agile controller ruby rails) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: huberto</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8448</link>
		<dc:creator>huberto</dc:creator>
		<pubDate>Fri, 05 Jun 2009 00:37:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8448</guid>
		<description>thanks. this was just what i needed to get through my issue. i was thinking about doing something along these lines to dry up my controllers but felt that this might be a bit hackish and cause me great pain down the road. this reassures that&#039;s not the case.

one thought though, wouldn&#039;t something like this be cleaner?

in the view:

render :partial =&gt; &#039;comments_form&#039; :object =&gt; @object_to_be_commented_on

and then call comments_form.class.to_s to generate the string constant from inside the comments_form partial?

-h</description>
		<content:encoded><![CDATA[<p>thanks. this was just what i needed to get through my issue. i was thinking about doing something along these lines to dry up my controllers but felt that this might be a bit hackish and cause me great pain down the road. this reassures that&#8217;s not the case.</p>
<p>one thought though, wouldn&#8217;t something like this be cleaner?</p>
<p>in the view:</p>
<p>render :partial =&gt; &#8216;comments_form&#8217; <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&gt; @object_to_be_commented_on</p>
<p>and then call comments_form.class.to_s to generate the string constant from inside the comments_form partial?</p>
<p>-h</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: André Durão</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8447</link>
		<dc:creator>André Durão</dc:creator>
		<pubDate>Mon, 25 May 2009 14:30:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8447</guid>
		<description>Hi there!
I found your topic very interesting, and help me a lot to understand polymorphism in rails..
I just got one question, maybe you know what I&#039;m doing wrong:
In my case I would like to use a has_one instead of has_many in my models, but it didn&#039;t worked, just with has_many it worked, is that some limitation of :as option?
thanks</description>
		<content:encoded><![CDATA[<p>Hi there!<br />
I found your topic very interesting, and help me a lot to understand polymorphism in rails..<br />
I just got one question, maybe you know what I&#8217;m doing wrong:<br />
In my case I would like to use a has_one instead of has_many in my models, but it didn&#8217;t worked, just with has_many it worked, is that some limitation of :as option?<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Simpson</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8446</link>
		<dc:creator>Matt Simpson</dc:creator>
		<pubDate>Sun, 03 May 2009 08:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8446</guid>
		<description>Great article, just what I was looking for.  Including all of the comments for how to enhance this method.  My controllers are going to be beautifully DRY! :o</description>
		<content:encoded><![CDATA[<p>Great article, just what I was looking for.  Including all of the comments for how to enhance this method.  My controllers are going to be beautifully DRY! <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mitch</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8445</link>
		<dc:creator>mitch</dc:creator>
		<pubDate>Tue, 24 Mar 2009 06:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8445</guid>
		<description>Nice discussion and examples. I do think dry can be taken too far when it means using inheritance just to isolate code. I mean, why should a User and a Meeting both inherit from the same class just because some of their methods have similar code? I agree that a module would be more appropriate.</description>
		<content:encoded><![CDATA[<p>Nice discussion and examples. I do think dry can be taken too far when it means using inheritance just to isolate code. I mean, why should a User and a Meeting both inherit from the same class just because some of their methods have similar code? I agree that a module would be more appropriate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nguma</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8444</link>
		<dc:creator>nguma</dc:creator>
		<pubDate>Sat, 20 Dec 2008 21:37:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8444</guid>
		<description>When it comes down to polymorphism and routing,
there&#039;s one really helpful trick:

polymorphic_url(@my_polymorphic_object)

it will redirect to the correct model, provided you have mapped its resources in routes.rb of course.</description>
		<content:encoded><![CDATA[<p>When it comes down to polymorphism and routing,<br />
there&#8217;s one really helpful trick:</p>
<p>polymorphic_url(@my_polymorphic_object)</p>
<p>it will redirect to the correct model, provided you have mapped its resources in routes.rb of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett Rasmussen</title>
		<link>http://pathfindersoftware.com/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/#comment-8443</link>
		<dc:creator>Brett Rasmussen</dc:creator>
		<pubDate>Fri, 24 Oct 2008 03:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1012#comment-8443</guid>
		<description>Josh, in your very first code snippet, you had

class Model &lt; ActiveRecord::Base

but if I&#039;m understanding all of this right, I think you meant

class Comment &lt; ActiveRecord::Base

Also, in the first snippet under &quot;Polymorphic Controllers&quot;, you&#039;re setting @klass as an instance variable in one line and then using it as just &quot;klass&quot; in the next line.

Just a couple of things I thought you might want to change for the sake of clarity to your readers. But thanks for the article; it was very useful to me.</description>
		<content:encoded><![CDATA[<p>Josh, in your very first code snippet, you had</p>
<p>class Model &lt; ActiveRecord::Base</p>
<p>but if I&#8217;m understanding all of this right, I think you meant</p>
<p>class Comment &lt; ActiveRecord::Base</p>
<p>Also, in the first snippet under &#8220;Polymorphic Controllers&#8221;, you&#8217;re setting @klass as an instance variable in one line and then using it as just &#8220;klass&#8221; in the next line.</p>
<p>Just a couple of things I thought you might want to change for the sake of clarity to your readers. But thanks for the article; it was very useful to me.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-10 03:01:38 -->
