I am trying to use utf-8 Tamil in a Rails application. When I edited
Tamil
unicode contents in a text
box and checked the output. The text got distorted when it is showing it
back.
I am trying to use utf-8 Tamil in a Rails application.
Are you using any plug-ins? I have an application that uses Mandarin
Chinese. It works beautifully with the standard installation of Rails
but when I added the Ferret text search plug-in, I could no longer use
Unicode.
Adding this as a before_filter to application.rb seems to fix things. It
makes sure that all rhtml files are set to utf8, and spares RJS from
setting
the content-type header so the code still executes.
# Switches to UTF8 charset
#
def configure_charsets
content_type = @headers["Content-Type"] || 'text/html'
if /^text\//.match(content_type)
@headers["Content-Type"] = "#{content_type}; charset=utf-8"
end
ActiveRecord::Base.connection.execute 'SET NAMES UTF8'
end
I apologize for pointing people to my blog and then having it tank.
I’m having some server issues.
Allow me to say that my solution is not as elegant as RaPT but in
case you’re interested, here is my install_plugins.rake (in the lib/
tasks directory)
require ‘yaml’
namespace :plugins do
desc “install a known list of plugins, specified in config/
base_plugins.yml”
task ‘install_base’ do
f = YAML::load_file(File.join(RAILS_ROOT, ‘config’,
‘base_plugins.yml’))
f.each_pair do |plugin, options|
force, svn = ‘’, ‘’
force = ’ --force’ if (options[:force] && options
[:force].downcase == ‘yes’)
svn = ’ -X’ if (options[:svn] && options
[:svn].downcase == ‘yes’)
if force.empty? && File.exist?(File.join(RAILS_ROOT,
“vendor/plugins/#{plugin}”))
puts “Skipping #{plugin} – already installed and
force options not specified.”
else
cmd = “ruby #{RAILS_ROOT}/script/plugin install #
{svn}#{options[‘repos’]} #{plugin}#{force}”
puts “*** installing #{cmd}”
system(cmd)
end
end
end
end
Here is my standard ‘base_plugins.yml’ (in the config directory)