With the default routing, the request /posts/:id gets mapped to the "show" action with :format => "html"
. I am using some xhtml elements in my show action which don't get rendered correctly unless the :content_type is set to xml. I am currently getting around this by rendering show.xml.erb and setting the content_type manually as follows:
format.html { render :template => "/posts/show.xml.erb",
:locals => {:post => @post}, :content_type => "text/xml" }
This seems silly though. How can I change routes.rb
so that /posts/:id is routed with format=>"xml"
? Thanks.