A RJS problem/patch

Hi,

add_rjs_to_action_view.rb of javascript_generator_templates
doesn’t work with setting Content-Type in a controller.
(e.g.) http://wiki.rubyonrails.org/rails/pages/HowtoSetDefaultEncoding

class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset
@headers[“Content-Type”] = “text/html; charset=utf-8”
end
end

I think it’s better to set it forcely.

— add_rjs_to_action_view.rb.old 2006-01-31 01:42:59.000000000
+0900
+++ add_rjs_to_action_view.rb 2006-01-31 01:43:29.000000000 +0900
@@ -50,10 +50,10 @@
body = case extension.to_sym
when :rxml
“xml = Builder::XmlMarkup.new(:indent => 2)\n” +

  •          "@controller.headers['Content-Type'] ||= 'text/xml'\n" +
    
  •          "@controller.headers['Content-Type'] = 'text/xml'\n" +
             template
           when :rjs
    
  •          "@controller.headers['Content-Type'] ||= 
    

‘text/javascript’\n" +

  •          "@controller.headers['Content-Type'] = 
    

‘text/javascript’\n" +
“update_page do |page|\n#{template}\nend”
end
else

I haven’t try CVS version of rails yet, but
actionpack/lib/action_view/base.rb seems to have same problem.

— base.rb.old 2006-01-31 02:05:28.000000000 +0900
+++ base.rb 2006-01-31 02:05:38.000000000 +0900
@@ -394,10 +394,10 @@
body = case extension.to_sym
when :rxml
“xml = Builder::XmlMarkup.new(:indent => 2)\n” +

  •          "@controller.headers['Content-Type'] ||= 'text/xml'\n" +
    
  •          "@controller.headers['Content-Type'] = 'text/xml'\n" +
             template
           when :rjs
    
  •          "@controller.headers['Content-Type'] ||= 
    

‘text/javascript’\n" +

  •          "@controller.headers['Content-Type'] = 
    

‘text/javascript’\n" +
“update_page do |page|\n#{template}\nend”
end
else

Masao,

The RJS plugin is created directly from the Rails trunk, but isn’t
supported by the Rails core team. This means that you’ll have to make
your patch against the Rails trunk by checking out Edge Rails from the
svn repository. Then you can make a ticket at
http://dev.rubyonrails.org with your patch and if your change is
accepted there it will also be added to the plugin.

On 1/30/06, Masao M. [email protected] wrote:

end

  •          "@controller.headers['Content-Type'] ||= 'text/xml'\n" +
    

actionpack/lib/action_view/base.rb seems to have same problem.
when :rjs
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset
@headers[“Content-Type”] = “text/html; charset=utf-8”
end
end

before_filter :set_charset, :except => [:rjs]


Rick O.
http://techno-weenie.net

Hi,

On Mon, 30 Jan 2006 14:10:51 -0500
Cody F. [email protected] wrote:

Masao,

The RJS plugin is created directly from the Rails trunk, but isn’t
supported by the Rails core team. This means that you’ll have to make
your patch against the Rails trunk by checking out Edge Rails from the
svn repository. Then you can make a ticket at
http://dev.rubyonrails.org with your patch and if your change is
accepted there it will also be added to the plugin.

Thanks. I’ll post it there, again.

Rick O. wrote:

class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset
@headers[“Content-Type”] = “text/html; charset=utf-8”
end
end

before_filter :set_charset, :except => [:rjs]

Alternatively:

class ApplicationController < ActionController::Base
after_filter :set_charset

def set_charset
@headers[“Content-Type”] ||= “text/html; charset=utf-8”
end
end

I’ve mentioned this on the wiki page too:
http://wiki.rubyonrails.org/rails/pages/HowtoSetDefaultEncoding

Rick, Richard,

Thanks for your information.

But I think it’s better it doesn’t have an effect
to application side.

On Mon, 30 Jan 2006 19:50:58 +0000