Rails routes and various XML templates

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

What's the best way to set up 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.

0


a source to share


1 answer


In your routes.rb file try

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

      



Then you can access params[:provider]

in your controller xml_data method to make a formatting decision.

+2


a source







All Articles