<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
	>
<channel>
	<title>Comments on: Ruby on Rails: Polymorphic Associations with Mixin Modules</title>
	<atom:link href="http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/feed/" rel="self" type="application/rss+xml" />
	<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/</link>
	<description>Writing Code is the Easy Part</description>
	<lastBuildDate>Tue, 24 Apr 2012 15:49:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ali</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-1177</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Fri, 21 Oct 2011 10:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-1177</guid>
		<description>Very useful, thanks for sharing, I would suggest using a block rather than a string:

  def self.included(base)
    base.instance_eval { has_many :impressions, :as =&gt; :impressionable }
  end</description>
		<content:encoded><![CDATA[<p>Very useful, thanks for sharing, I would suggest using a block rather than a string:</p>
<p>  def self.included(base)<br />
    base.instance_eval { has_many :impressions, :as =&gt; :impressionable }<br />
  end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to add a Ruby on Rails association from inside a module/mixin &#171; The Missing Readme</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-548</link>
		<dc:creator>How to add a Ruby on Rails association from inside a module/mixin &#171; The Missing Readme</dc:creator>
		<pubDate>Thu, 23 Sep 2010 02:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-548</guid>
		<description>[...] associations in a mixin. Doing so however is a bit of a black art. I found out how to do this from www.teachmetocode.com (and the code below includes the hint from Stefan Kanev&#8217;s [...] </description>
		<content:encoded><![CDATA[<p>[...] associations in a mixin. Doing so however is a bit of a black art. I found out how to do this from <a href="http://www.teachmetocode.com" rel="nofollow">http://www.teachmetocode.com</a> (and the code below includes the hint from Stefan Kanev&#8217;s [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: http://charlesmaxwood.com/ruby-on-rails-&#8230; &#171; bst On Web Dev</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-547</link>
		<dc:creator>http://charlesmaxwood.com/ruby-on-rails-&#8230; &#171; bst On Web Dev</dc:creator>
		<pubDate>Tue, 18 Aug 2009 00:53:37 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-547</guid>
		<description>[...]  12:53 am on August 18, 2009  Permalink &#124; Reply   Tags: app design, rails (9)    http://charlesmaxwood.com/ruby-on-rails-polymorphic-associations-with-mixin-modules/ &#8211; Ruby on Rails: Polymorphic Associations with Mixin Modules   [...] </description>
		<content:encoded><![CDATA[<p>[...]  12:53 am on August 18, 2009  Permalink | Reply   Tags: app design, rails (9)    <a href="http://charlesmaxwood.com/ruby-on-rails-polymorphic-associations-with-mixin-modules/" rel="nofollow">http://charlesmaxwood.com/ruby-on-rails-polymorphic-associations-with-mixin-modules/</a> &#8211; Ruby on Rails: Polymorphic Associations with Mixin Modules   [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rails Metal Example #7: Tracking Analytics</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-546</link>
		<dc:creator>Rails Metal Example #7: Tracking Analytics</dc:creator>
		<pubDate>Tue, 11 Aug 2009 05:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-546</guid>
		<description>[...] week ago, I posted Ruby on Rails: Polymorphic Associations with Mixin Modules which included an example of tracking impressions on different [...] </description>
		<content:encoded><![CDATA[<p>[...] week ago, I posted Ruby on Rails: Polymorphic Associations with Mixin Modules which included an example of tracking impressions on different [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wojciech</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-545</link>
		<dc:creator>Wojciech</dc:creator>
		<pubDate>Mon, 03 Aug 2009 07:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-545</guid>
		<description>add_impression isn&#039;t necessary, as ActiveRecord&#039;s association proxies provide us with some methods like:
&lt;code&gt;
some_record.impressions.create :visitor=&gt;visitor
&lt;/code&gt;
- no need to pass :impressionable=&gt;self

Of course you can wrap this in a custom method for abstraction:
&lt;code&gt;
def impression( visitor )
  self.impressions.create :visitor=&gt;visitor
end
&lt;/code&gt;

But I recommend against creating such abstractions until it&#039;s necessary - there&#039;s a good chance ActiveRecord associations will do. You can even extend them, take a look at &quot;association extensions&quot;:
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html</description>
		<content:encoded><![CDATA[<p>add_impression isn&#8217;t necessary, as ActiveRecord&#8217;s association proxies provide us with some methods like:<br />
<code><br />
some_record.impressions.create :visitor=&gt;visitor<br />
</code><br />
- no need to pass :impressionable=&gt;self</p>
<p>Of course you can wrap this in a custom method for abstraction:<br />
<code><br />
def impression( visitor )<br />
  self.impressions.create :visitor=&gt;visitor<br />
end<br />
</code></p>
<p>But I recommend against creating such abstractions until it&#8217;s necessary &#8211; there&#8217;s a good chance ActiveRecord associations will do. You can even extend them, take a look at &#8220;association extensions&#8221;:<br />
<a href="http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html" rel="nofollow">http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: drool</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-544</link>
		<dc:creator>drool</dc:creator>
		<pubDate>Fri, 31 Jul 2009 20:25:57 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-544</guid>
		<description>This is how DataMapper suggests to handle polymorphic relationships within it (as opposed to using STI).</description>
		<content:encoded><![CDATA[<p>This is how DataMapper suggests to handle polymorphic relationships within it (as opposed to using STI).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Kanev</title>
		<link>http://teachmetocode.com/articles/ruby-on-rails-polymorphic-associations-with-mixin-modules/#comment-543</link>
		<dc:creator>Stefan Kanev</dc:creator>
		<pubDate>Fri, 31 Jul 2009 18:59:09 +0000</pubDate>
		<guid isPermaLink="false">http://charlesmaxwood.com/?p=351#comment-543</guid>
		<description>You don&#039;t need the instance eval. You can simply do base.has_many

I tend to end up doing this every time I use a polymorphic relationship</description>
		<content:encoded><![CDATA[<p>You don&#8217;t need the instance eval. You can simply do base.has_many</p>
<p>I tend to end up doing this every time I use a polymorphic relationship</p>
]]></content:encoded>
	</item>
</channel>
</rss>

