Read more

Define a route that only responds to a specific format

Henning Koch
April 03, 2012Software engineer at makandra GmbH

You won't usually have to do this. It's OK to route all formats to a controller, and let the controller decide to which format it wants to respond.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Should you for some reason want to define a route that only responds to a given format, here is how you do it:

Rails 3

match 'sitemap.xml' => 'feeds#sitemap', :constraints => { :format => 'xml' }, :as => 'sitemap'

Rails 2

map.sitemap 'sitemap.xml', :controller => 'feeds', :action => 'sitemap', :format => 'xml'
Posted by Henning Koch to makandra dev (2012-04-03 17:28)