[Rails] Frustrated with RoR environment splintering
Tom Mornini
tmornini at infomania.com
Sat Apr 1 08:20:04 GMT 2006
On Mar 31, 2006, at 11:09 PM, Calle Dybedahl wrote:
> (Now, if I could just figure out how to tell lighttpd to set the
> charset to UTF-8 by default like WEBrick does, I'd try that one out
> too.)
I didn't write this code, and I don't have the original attribution.
I'm almost certain it came from the Rails Wiki
Put this in application.rb
def set_content_type
if not request.env['HTTP_ACCEPT'].nil? and
( request.env['HTTP_ACCEPT'].index('application/xhtml+xml') or
request.env['HTTP_ACCEPT'].index('*/*') )
headers['Content-Type'] = "application/xhtml+xml; charset=utf-8"
else
headers['Content-Type'] = "text/html; charset=utf-8"
end
end
And set after_filter for all controllers.
--
-- Tom Mornini
More information about the Rails
mailing list