Forum: Ruby on Rails Using unicode_hacks breaks Rails 1.1 RJS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Zak M. (Guest)
on 2006-04-23 22:38
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_plugin...
for "multi-lingual
support":[http://wiki.rubyonrails.com/rails/pages/HowToUseUn...]
(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
This topic is locked and can not be replied to.