I have Rails 1.1, MySql 5.0 and would like to stor text as utf8 in the
db.
I have changed the character set and collation in the db to utf8 and
utf8_danish_ci - also checked the mysql to if its ok:
show collations like “%danish%”;
utf8_danish_ci utf8 203 Yes 8
I then add the following
environment.rb:
$KCODE = ‘u’
require ‘jcode’
och database.yml
encoding: utf8
If I then restart the webserver I get:
Character set ‘utf8’ is not a compiled character set and is not
specified in the ‘/usr/local/mysql/share/mysql/charsets/Index’ file
rake aborted!
Can’t initialize character set utf8 (path:
/usr/local/mysql/share/mysql/charsets/)
First thought that I was missing the charset but it was ok.
Then I removed encoding: utf8 and added the following to my application
controller:
before_filter :configure_charsets
def configure_charsets
headers[“Content-Type”] = “text/html; charset=utf-8”
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end
This then works fine. Has anyone else encountered the same or have a
solution?