<?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: Single Table Inheritance and RESTful Routes</title>
	<atom:link href="http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/</link>
	<description>Logical Reality Design: Web Design and Software Development</description>
	<lastBuildDate>Wed, 14 Jul 2010 20:46:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Jimmy</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-15160</link>
		<dc:creator>Jimmy</dc:creator>
		<pubDate>Wed, 14 Jul 2010 20:46:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-15160</guid>
		<description>Wish i found this post about two hours ago, thanks!</description>
		<content:encoded><![CDATA[<p>Wish i found this post about two hours ago, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark S</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-14184</link>
		<dc:creator>Mark S</dc:creator>
		<pubDate>Mon, 24 May 2010 11:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-14184</guid>
		<description>I achieved this globally by overriding the following :

module ActionController
  module RecordIdentifier
    private
    def model_name_from_record_or_class(record_or_class)
      (record_or_class.is_a?(Class) ? record_or_class.base_class : record_or_class.class.base_class).model_name
    end
  end
end

The same can be achieved only for specific STI cases with :

@subclassRecord.becomes(BaseClassName)

This saves having extra routes to trawl through and so forth.</description>
		<content:encoded><![CDATA[<p>I achieved this globally by overriding the following :</p>
<p>module ActionController<br />
  module RecordIdentifier<br />
    private<br />
    def model_name_from_record_or_class(record_or_class)<br />
      (record_or_class.is_a?(Class) ? record_or_class.base_class : record_or_class.class.base_class).model_name<br />
    end<br />
  end<br />
end</p>
<p>The same can be achieved only for specific STI cases with :</p>
<p>@subclassRecord.becomes(BaseClassName)</p>
<p>This saves having extra routes to trawl through and so forth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-13247</link>
		<dc:creator>Casper</dc:creator>
		<pubDate>Thu, 15 Apr 2010 10:16:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-13247</guid>
		<description>Thank you, this saved me some time.</description>
		<content:encoded><![CDATA[<p>Thank you, this saved me some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claudio</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-13063</link>
		<dc:creator>Claudio</dc:creator>
		<pubDate>Thu, 01 Apr 2010 20:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-13063</guid>
		<description>Thank you Evan your solution is very helpful for me!</description>
		<content:encoded><![CDATA[<p>Thank you Evan your solution is very helpful for me!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-10743</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 07 Jan 2010 20:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-10743</guid>
		<description>Another thank you - I ran into the same situation converting an old app, and you saved me a lot of time!</description>
		<content:encoded><![CDATA[<p>Another thank you &#8211; I ran into the same situation converting an old app, and you saved me a lot of time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-8689</link>
		<dc:creator>Evan</dc:creator>
		<pubDate>Thu, 29 Oct 2009 21:01:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-8689</guid>
		<description>Javix:  The primary reason I do things this way is because, for most purposes, I don&#039;t want to distinguish the different types of tasks in the controller.   They&#039;re nearly identical and I want to use the same code.   The whole point of the exercise is that ActionItems, WorkOrders etc. all use the same controller action and views so I don&#039;t have to write them twice.  

For the few things that need to be different -- for example, ProblemReports have one fewer column in the table view than AIs or WOs -- I can have my views or controllers check @task.type.  For example, in app/views/tasks/show.html.erb I might have this line:

&lt;code&gt;
&lt;%- unless @task.type == &#039;problem_report&#039; %&gt;
  &lt;td&gt;&lt;%= h @task.some_field_that_problem_reports_dont_use %&gt;&lt;/td&gt;
&lt;% end %&gt; 
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Javix:  The primary reason I do things this way is because, for most purposes, I don&#8217;t want to distinguish the different types of tasks in the controller.   They&#8217;re nearly identical and I want to use the same code.   The whole point of the exercise is that ActionItems, WorkOrders etc. all use the same controller action and views so I don&#8217;t have to write them twice.  </p>
<p>For the few things that need to be different &#8212; for example, ProblemReports have one fewer column in the table view than AIs or WOs &#8212; I can have my views or controllers check @task.type.  For example, in app/views/tasks/show.html.erb I might have this line:</p>
<p><code><br />
< %- unless @task.type == 'problem_report' %></p>
<td>< %= h @task.some_field_that_problem_reports_dont_use %></td>
<p>< % end %><br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javix</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-8259</link>
		<dc:creator>Javix</dc:creator>
		<pubDate>Sat, 17 Oct 2009 21:01:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-8259</guid>
		<description>sorry for the typo in my mail address</description>
		<content:encoded><![CDATA[<p>sorry for the typo in my mail address</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javix</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-8258</link>
		<dc:creator>Javix</dc:creator>
		<pubDate>Sat, 17 Oct 2009 20:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-8258</guid>
		<description>One more question, - how to distinguish actionitems from others (work_orders, problems_reports) in your controller (new, create, edit, update) and how to create the views? Should I create a seperate folder for every subclass with coresponding views (new, edit, etc.) ?Thanks.</description>
		<content:encoded><![CDATA[<p>One more question, &#8211; how to distinguish actionitems from others (work_orders, problems_reports) in your controller (new, create, edit, update) and how to create the views? Should I create a seperate folder for every subclass with coresponding views (new, edit, etc.) ?Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-7468</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 09 Sep 2009 01:00:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-7468</guid>
		<description>Thanks for this one.  Exact same situation for me.  Knew there had to be something better than what I was originally up to.</description>
		<content:encoded><![CDATA[<p>Thanks for this one.  Exact same situation for me.  Knew there had to be something better than what I was originally up to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fretta</title>
		<link>http://blog.lrdesign.com/2009/03/single-table-inheritance-and-restful-routes/comment-page-1/#comment-7399</link>
		<dc:creator>Fretta</dc:creator>
		<pubDate>Fri, 04 Sep 2009 17:11:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=52#comment-7399</guid>
		<description>Great post! Was about to start pulling my hair. Thanks Evan.</description>
		<content:encoded><![CDATA[<p>Great post! Was about to start pulling my hair. Thanks Evan.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
