[typo] how does typo produce feed urls with ".xml" suffix?

Piers Cawley pdcawley at bofh.org.uk
Fri Mar 31 01:03:07 EST 2006

Stephen Bannasch <stephen at deanbrook.org> writes:

> I'm pretty new to Ruby and Rails and I like to be able to create urls 
> with an extension suffix similar to how Typo does this for the feed 
> urls. However I need a bit of help understanding how this works in 
> Typo.
> The Sidebar 'Articles' feed is generated here:
> components/plugins/sidebars/xml/content.rhtml
> with this script fragment:
> <%= url_for :controller=>'xml', :action=>'feed', :format => 
> @sb_config['format'], :type => 'trackbacks' %>
> In my case @sb_config['format'] == 'rss20' and it produces urls in 
> the following form:
> http://localhost:3000/xml/rss20/feed.xml
> config/route.rb processes this url with this map:
> map.xml 'xml/rss', :controller => 'xml', :action => 'feed', :type => 
> 'feed', :format => 'rss'
> So clicking on the link runs XmlController#feed in 
> apps/controllers/xml_controller.rb. Which calls the renderer at 
> views/xml/rss20_feed.rxml (and a partial) which actually generates 
> the xml feed.
> I've discovered that if I take out ':format => @sb_config['format']' 
> from the url_for link the '.xml' suffix is no longer generated but 
> I'm having trouble going further.

The magic's all in config/routes.rb

Notice that we add the .xml extension there.

Piers Cawley <pdcawley at bofh.org.uk>

More information about the Typo-list mailing list