<?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"
	>
<channel>
	<title>Comments on: Rails STI resouce routes routing</title>
	<atom:link href="http://blog.edseek.com/archives/2008/04/12/rails-sti-resouce-routes-routing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.edseek.com/archives/2008/04/12/rails-sti-resouce-routes-routing/</link>
	<description>"Banking establishments are more dangerous than standing armies." -- Thomas Jefferson</description>
	<pubDate>Tue, 02 Dec 2008 13:29:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: jasonb</title>
		<link>http://blog.edseek.com/archives/2008/04/12/rails-sti-resouce-routes-routing/#comment-35953</link>
		<dc:creator>jasonb</dc:creator>
		<pubDate>Mon, 20 Oct 2008 22:17:51 +0000</pubDate>
		<guid isPermaLink="false">http://edseek.com/?p=390#comment-35953</guid>
		<description>I need to figure out how to enable some tags for comments...</description>
		<content:encoded><![CDATA[<p>I need to figure out how to enable some tags for comments&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Hoskins</title>
		<link>http://blog.edseek.com/archives/2008/04/12/rails-sti-resouce-routes-routing/#comment-35952</link>
		<dc:creator>Jim Hoskins</dc:creator>
		<pubDate>Mon, 20 Oct 2008 20:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://edseek.com/?p=390#comment-35952</guid>
		<description>The comment ate that code. I'll try one more time

module ActionController
  module PolymorphicRoutes
    def build_named_route_call(records, namespace, inflection, options = {})
      unless records.is_a?(Array)
        record = extract_record(records)
        route = ''
      else
        record = records.pop
        route = records.inject("") do &#124;string, parent&#124;
          if parent.is_a?(Symbol) &#124;&#124; parent.is_a?(String)
            string &#60;&#60; "#{parent}_"
          else
            string &#60;&#60; "#{RecordIdentifier.send!("singular_class_name", parent)}_" 
          end
        end
      end
      
      if record.is_a?(Symbol) &#124;&#124; record.is_a?(String)
        route &#60;&#60; "#{record}_"
      else
        record = record.class unless record.is_a?(Class)
        until (record.superclass == ::ActiveRecord::Base)
          record = record.superclass
        end
        route &#60;&#60; "#{RecordIdentifier.send!("#{inflection}_class_name", record)}_"
      end
     
      action_prefix(options) + namespace + route + routing_type(options).to_s
    end
  end
end</description>
		<content:encoded><![CDATA[<p>The comment ate that code. I&#8217;ll try one more time</p>
<p>module ActionController<br />
  module PolymorphicRoutes<br />
    def build_named_route_call(records, namespace, inflection, options = {})<br />
      unless records.is_a?(Array)<br />
        record = extract_record(records)<br />
        route = &#8221;<br />
      else<br />
        record = records.pop<br />
        route = records.inject(&#8221;") do |string, parent|<br />
          if parent.is_a?(Symbol) || parent.is_a?(String)<br />
            string &lt;&lt; &#8220;#{parent}_&#8221;<br />
          else<br />
            string &lt;&lt; &#8220;#{RecordIdentifier.send!(&#8221;singular_class_name&#8221;, parent)}_&#8221;<br />
          end<br />
        end<br />
      end</p>
<p>      if record.is_a?(Symbol) || record.is_a?(String)<br />
        route &lt;&lt; &#8220;#{record}_&#8221;<br />
      else<br />
        record = record.class unless record.is_a?(Class)<br />
        until (record.superclass == ::ActiveRecord::Base)<br />
          record = record.superclass<br />
        end<br />
        route &lt;&lt; &#8220;#{RecordIdentifier.send!(&#8221;#{inflection}_class_name&#8221;, record)}_&#8221;<br />
      end</p>
<p>      action_prefix(options) + namespace + route + routing_type(options).to_s<br />
    end<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Hoskins</title>
		<link>http://blog.edseek.com/archives/2008/04/12/rails-sti-resouce-routes-routing/#comment-35951</link>
		<dc:creator>Jim Hoskins</dc:creator>
		<pubDate>Mon, 20 Oct 2008 20:26:17 +0000</pubDate>
		<guid isPermaLink="false">http://edseek.com/?p=390#comment-35951</guid>
		<description>For rails 2.1, this code doesn't quite work. I have tweaked it, and this seems to work for me. Just throw this into a file in your config/initializers folder.

-----8&#60;--------------
module ActionController
  module PolymorphicRoutes
    def build_named_route_call(records, namespace, inflection, options = {})
      unless records.is_a?(Array)
        record = extract_record(records)
        route = ''
      else
        record = records.pop
        route = records.inject("") do &#124;string, parent&#124;
          if parent.is_a?(Symbol) &#124;&#124; parent.is_a?(String)
            string &#60;&#60; "#{parent}_"
          else
            string &#60;&#60; "#{RecordIdentifier.send!("singular_class_name", parent)}_" 
          end
        end
      end
      
      if record.is_a?(Symbol) &#124;&#124; record.is_a?(String)
        route &#60;&#60; "#{record}_"
      else
        record = record.class unless record.is_a?(Class)
        until (record.superclass == ::ActiveRecord::Base)
          record = record.superclass
        end
        route &#60;8--------------

Thanks for this post, it got me 90% there!</description>
		<content:encoded><![CDATA[<p>For rails 2.1, this code doesn&#8217;t quite work. I have tweaked it, and this seems to work for me. Just throw this into a file in your config/initializers folder.</p>
<p>&#8212;&#8211;8&lt;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
module ActionController<br />
  module PolymorphicRoutes<br />
    def build_named_route_call(records, namespace, inflection, options = {})<br />
      unless records.is_a?(Array)<br />
        record = extract_record(records)<br />
        route = &#8221;<br />
      else<br />
        record = records.pop<br />
        route = records.inject(&#8221;") do |string, parent|<br />
          if parent.is_a?(Symbol) || parent.is_a?(String)<br />
            string &lt;&lt; &#8220;#{parent}_&#8221;<br />
          else<br />
            string &lt;&lt; &#8220;#{RecordIdentifier.send!(&#8221;singular_class_name&#8221;, parent)}_&#8221;<br />
          end<br />
        end<br />
      end</p>
<p>      if record.is_a?(Symbol) || record.is_a?(String)<br />
        route &lt;&lt; &#8220;#{record}_&#8221;<br />
      else<br />
        record = record.class unless record.is_a?(Class)<br />
        until (record.superclass == ::ActiveRecord::Base)<br />
          record = record.superclass<br />
        end<br />
        route &lt;8&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Thanks for this post, it got me 90% there!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
