<?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: Multiple Table Inheritance with ActiveRecord</title>
	<atom:link href="http://mediumexposure.com/multiple-table-inheritance-active-record/feed/" rel="self" type="application/rss+xml" />
	<link>http://mediumexposure.com/multiple-table-inheritance-active-record/</link>
	<description>by Maxim Chernyak</description>
	<lastBuildDate>Thu, 15 Jul 2010 14:57:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John York</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3516</link>
		<dc:creator>John York</dc:creator>
		<pubDate>Sat, 10 Jul 2010 18:32:13 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3516</guid>
		<description>&lt;p&gt;Eric, I just had the same problem, and it was because my table wasn&#039;t defined properly. the product_properties table must have at least the following columns:&lt;/p&gt;

&lt;p&gt;id
sellable_type
sellable_id&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Eric, I just had the same problem, and it was because my table wasn&#8217;t defined properly. the product_properties table must have at least the following columns:</p>

<p>id
sellable_type
sellable_id</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Green</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3419</link>
		<dc:creator>Anthony Green</dc:creator>
		<pubDate>Sat, 26 Jun 2010 12:28:51 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3419</guid>
		<description>&lt;p&gt;I&#039;ve been using the same pattern as Ron. I prefer using delegate over method_missing to avoid too much metamagic obviscation.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been using the same pattern as Ron. I prefer using delegate over method_missing to avoid too much metamagic obviscation.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Phillip</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3358</link>
		<dc:creator>Phillip</dc:creator>
		<pubDate>Mon, 21 Jun 2010 14:39:31 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3358</guid>
		<description>&lt;p&gt;Hi,
this is really a nice approach!&lt;/p&gt;

&lt;p&gt;Did you thought about including dynamic finders ? If you just send them to the product_properties class you will get a product_properties object as return and not, as you may want, a pen or a tee object with all the necessary data. Maybe you have something in mind i haven&#039;t thought of yet.&lt;/p&gt;

&lt;p&gt;thanks anyway for your sharing.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,
this is really a nice approach!</p>

<p>Did you thought about including dynamic finders ? If you just send them to the product_properties class you will get a product_properties object as return and not, as you may want, a pen or a tee object with all the necessary data. Maybe you have something in mind i haven&#8217;t thought of yet.</p>

<p>thanks anyway for your sharing.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan L</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3356</link>
		<dc:creator>Bryan L</dc:creator>
		<pubDate>Mon, 21 Jun 2010 11:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3356</guid>
		<description>&lt;p&gt;This has been extremely helpful to me. One issue I&#039;ve got is that I can&#039;t do eager loading with this. I get this error:&lt;/p&gt;

&lt;p&gt;Can not eagerly load the polymorphic association :sellable&lt;/p&gt;

&lt;p&gt;Would anyone know how to modify it so that we can do eager loading? I would like to reduce the N+1 queries. Thanks!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This has been extremely helpful to me. One issue I&#8217;ve got is that I can&#8217;t do eager loading with this. I get this error:</p>

<p>Can not eagerly load the polymorphic association :sellable</p>

<p>Would anyone know how to modify it so that we can do eager loading? I would like to reduce the N+1 queries. Thanks!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Evgeniy Dolzhenko</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3329</link>
		<dc:creator>Evgeniy Dolzhenko</dc:creator>
		<pubDate>Fri, 18 Jun 2010 05:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3329</guid>
		<description>&lt;p&gt;Something that burned me a few times ago:&lt;/p&gt;

&lt;p&gt;public_methods.include?(meth.to_s)&lt;/p&gt;

&lt;p&gt;won&#039;t work on 1.9 since method names would be returned as array of symbols instead of an array of strings&lt;/p&gt;

&lt;p&gt;public_methods.map(&amp;:to_sym).include?(meth.to_sym)&lt;/p&gt;

&lt;p&gt;should work across different versions I think.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Something that burned me a few times ago:</p>

<p>public_methods.include?(meth.to_s)</p>

<p>won&#8217;t work on 1.9 since method names would be returned as array of symbols instead of an array of strings</p>

<p>public_methods.map(&amp;:to_sym).include?(meth.to_sym)</p>

<p>should work across different versions I think.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Coulthard</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-3260</link>
		<dc:creator>Eric Coulthard</dc:creator>
		<pubDate>Thu, 10 Jun 2010 10:08:15 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-3260</guid>
		<description>&lt;p&gt;Would you be able to add which files the code would go in and their path in the rails directory structure? I am trying to recreate what you have done for my project and I cannot since when I try to &#039;rake db:seed&#039; it tells me that acts_as_product is undefined. If I replace the call with &#039;include Sellable&#039; I get &#039;undefined method sellable_type=...&#039;&lt;/p&gt;

&lt;p&gt;I am new at this so any help you could give would be greatly appreciated.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Would you be able to add which files the code would go in and their path in the rails directory structure? I am trying to recreate what you have done for my project and I cannot since when I try to &#8216;rake db:seed&#8217; it tells me that acts_as_product is undefined. If I replace the call with &#8216;include Sellable&#8217; I get &#8216;undefined method sellable_type=&#8230;&#8217;</p>

<p>I am new at this so any help you could give would be greatly appreciated.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ron</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-2890</link>
		<dc:creator>Ron</dc:creator>
		<pubDate>Sun, 16 May 2010 04:01:29 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-2890</guid>
		<description>&lt;p&gt;I&#039;m using a slightly different technique.   I think it&#039;s roughly similar, but it goes something like:&lt;/p&gt;

&lt;p&gt;class Product &lt; ActiveRecord::Base
  self.abstract_class = true
  has_one :product_properties, :as =&gt; :product, :dependent =&gt; :destroy
  delegate :price, :price=, :name, :name=, :description, :description=, :to =&gt; :product_properties
  def product_properties_with_autobuild
      product_properties_without_autobuild &#124;&#124; build_product_properties
  end
  alias_method_chain :product_properties, :autobuild
end&lt;/p&gt;

&lt;p&gt;Then just inherit your products from Product.&lt;/p&gt;

&lt;p&gt;This mostly works in rails 3, but isn&#039;t perfect.   I&#039;ve been waiting for a decent CTI implementation for activerecord for years.  I have a project that relies on it very heavily.  Anyone know of an ORM that supports it properly?  Can DataMapper do it?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;m using a slightly different technique.   I think it&#8217;s roughly similar, but it goes something like:</p>

<p>class Product &lt; ActiveRecord::Base
  self.abstract_class = true
  has_one :product_properties, :as =&gt; :product, :dependent =&gt; :destroy
  delegate :price, :price=, :name, :name=, :description, :description=, :to =&gt; :product_properties
  def product_properties_with_autobuild
      product_properties_without_autobuild || build_product_properties
  end
  alias_method_chain :product_properties, :autobuild
end</p>

<p>Then just inherit your products from Product.</p>

<p>This mostly works in rails 3, but isn&#8217;t perfect.   I&#8217;ve been waiting for a decent CTI implementation for activerecord for years.  I have a project that relies on it very heavily.  Anyone know of an ORM that supports it properly?  Can DataMapper do it?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bruno Pinto</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-2683</link>
		<dc:creator>Bruno Pinto</dc:creator>
		<pubDate>Thu, 29 Apr 2010 02:34:08 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-2683</guid>
		<description>&lt;p&gt;@hakunin&lt;/p&gt;

&lt;p&gt;First, thank you so much, this is the best post I have ever seen about MTI on rails.&lt;/p&gt;

&lt;p&gt;However, I had one problem when using :include.&lt;/p&gt;

&lt;p&gt;Example:
class Pen &lt; ActiveRecord::Base
  include Sellable
end&lt;/p&gt;

&lt;p&gt;class Pack
  belongs_to :pen&lt;/p&gt;

&lt;p&gt;named_scope :with_product_properties, :include =&gt; { :pen =&gt; { product_properties =&gt; title }
end&lt;/p&gt;

&lt;p&gt;So, if I try to use @pack = Pack.with_product_properties
@pack.pen.title it says that title is an unknown property for this &#039;aggregation  however @pack.pen.product_properties.title is okay.&lt;/p&gt;

&lt;p&gt;If you need more info, I could create a code to reproduce this error.&lt;/p&gt;

&lt;p&gt;Thanks in advance!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@hakunin</p>

<p>First, thank you so much, this is the best post I have ever seen about MTI on rails.</p>

<p>However, I had one problem when using :include.</p>

<p>Example:
class Pen &lt; ActiveRecord::Base
  include Sellable
end</p>

<p>class Pack
  belongs_to :pen</p>

<p>named_scope :with_product_properties, :include =&gt; { :pen =&gt; { product_properties =&gt; title }
end</p>

<p>So, if I try to use @pack = Pack.with_product_properties
@pack.pen.title it says that title is an unknown property for this &#8216;aggregation  however @pack.pen.product_properties.title is okay.</p>

<p>If you need more info, I could create a code to reproduce this error.</p>

<p>Thanks in advance!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan L.</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-2537</link>
		<dc:creator>Bryan L.</dc:creator>
		<pubDate>Thu, 22 Apr 2010 04:02:41 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-2537</guid>
		<description>&lt;p&gt;Bummer, nevermind. Just after posting the previous comment, I figured you can just do &quot;p.sellable.color&quot; and it&#039;ll work fine. How dumb of me.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Bummer, nevermind. Just after posting the previous comment, I figured you can just do &#8220;p.sellable.color&#8221; and it&#8217;ll work fine. How dumb of me.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan L.</title>
		<link>http://mediumexposure.com/multiple-table-inheritance-active-record/comment-page-1/#comment-2536</link>
		<dc:creator>Bryan L.</dc:creator>
		<pubDate>Thu, 22 Apr 2010 03:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://mediumexposure.com/?p=68#comment-2536</guid>
		<description>&lt;p&gt;Thanks a lot for sharing this code! I&#039;ve been interested in MTI in Rails for quite some time.&lt;/p&gt;

&lt;p&gt;Is it possible to modify the code a little so that it supports something like:&lt;/p&gt;

&lt;p&gt;@productproperties = ProductProperties.all
@productproperties.each do &#124;p&#124;
    print p.tee.color
end&lt;/p&gt;

&lt;p&gt;This would be extremely useful. Thanks.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks a lot for sharing this code! I&#8217;ve been interested in MTI in Rails for quite some time.</p>

<p>Is it possible to modify the code a little so that it supports something like:</p>

<p>@productproperties = ProductProperties.all
@productproperties.each do |p|
    print p.tee.color
end</p>

<p>This would be extremely useful. Thanks.</p>]]></content:encoded>
	</item>
</channel>
</rss>
