views:

100

answers:

1

My application needs to provide the same data in XML to 2 different providers that have specific formatting requests.

What's the best way to setup my routes so that I can have the following:

http://www.site.com/posts/provider1.xml
http://www.site.com/posts/provider2.xml

(Where provider 1 and 2 are separate templates)

Thanks.

+2  A: 

In your routes.rb file, try

map.xml_posts 'posts/:provider.xml', :controller => 'posts', :action => 'xml_data'

You can then access params[:provider] in your controller's xml_data method to decide on the formatting.

adnan.