iA


Rails, Content – Type, RJS and filters

by jcf. Average Reading Time: less than a minute.

Again – one of these “it takes several hours” to find it things:

In an inherited application that I’m expanding, I was using RJS actions to handle inserts:

page.insert_html :bottom, 'info_list', :partial => 'info'

Because of some non-showing Umlauts, I switched on a filter to set the content type:


    class ApplicationController < ActionController::Base
      before_filter :set_charset

      def set_charset
        headers['Content - Type'] = "text/html; charset=8859-1"
      end
    end

with the result, that all my RJS stuff stopped working. Finally I diffed against a working copy and found the line enabling the filter. I rewrote it like this, and things started to work again


    class ApplicationController < ActionController::Base
      after_filter :set_charset

      def set_charset
        headers['Content - Type'] ||= "text/html; charset=8859-1"      
      end
    end

spot the two differences….

Also – I found out that ecto and WordPress don’t like it at all, if you try to have something called “Content – Type” (without the spaces) in an entry and try to publish it.

Technorati Tags: ,

No comments on ‘Rails, Content – Type, RJS and filters’

Leave a Reply