Ruby, Rails, Render, and the Content-Type HTTP header

Don't you hate it when you google for 30 minutes, trying to solve a simple problem, but for some reason the right combination of terms--or at least the combination of terms you think is right--fails.

It just happened to me with a simple problem: change the Content-Type HTTP Response Header for using standard Rails templates to be text/xml.

The solution is pretty straight-forward:
response.headers["Content-Type"] = 'text/xml'
...as I eventually found here.

Setting this hash value in your ActionController action method does the trick.

Here's hoping google picks this up and saves someone 20 minutes.