rails 1.2 default charset override

Ruby on Rails 1.2 and above automatically set a Content-type header including charset=UTF-8, which is well and good if you’re designing an application from scratch – JoelOnSoftware has a good introduction to character sets, for those who need a refresher – but breaks things in subtle ways if you are upgrading a legacy Rails 1.1 application. The (poorly documented at best) solution to this problem is to add a line to the config block of environment.rb to set config.action_controller.default_charset:

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