Using unicode_hacks breaks Rails 1.1 RJS

All,

I wasted an hour on this, so here’s a quick post to save you from the
same. If you are using
“unicode_hacks”:http://julik.textdriven.com/svn/tools/rails_plugins/unicode_hacks/
for “multi-lingual
support”:[Peak Obsession]
(i18n), there’s a gotcha - RJS templates will not work.

The culprit is line #4 in lib\actionpack_filters.rb, which sets the
character set in the HTTP header to UTF so that old browsers can render
the properly. It also sets the content-type to text/html. For RJS, the
content-type needs to be text/javascript.

Here’s a quick fix that worked for me, replace line #4 with

response.headers[“Content-Type”] = “text/html; charset=utf-8” if not
request.xhr?

  • Zak