Ruby on rails x charset

character-encodingrubyruby-on-rails

i'm having problem to deal with charset in ruby on rails app, specificially in my templates. Code that comes from my database, works fine, but codes like ç ~ that are located in my views are not working. I added the following codes to my code

I added a function like that, but that still not working i have ç ~ codes in my application.rhtml that are not working.

before_filter :configure_charsets 
 # Configuring charset to UTF-8 def configure_charsets    
 headers["Content-Type"] = "text/html; charset=UTF-8"     
end

I added as well meta http-equiv html to utf-8 and a .htaccess parameter AddDefaultCharset UTF-8

That's still not working, any other tip?

Best Solution

Put this piece of code in your config (environment.rb)

Rails::Initializer.run do |config|
  config.action_controller.default_charset = "iso-8859-1"
end

This will do it.

Also, remove the default charset line if any in layouts/application.html