Get Ruby 1.9, Rails, MySQL and UTF-8 to Work Together
Here’s a quick little hack to get MySQL 2.8.1 using UTF-8 in Rails 2.3.4 and Ruby 1.9.1.
Put that snippet in your Rails project (I used lib/mysql_utf8.rb) and load it in your environment.
That's all. Now your queries should use Unicode:
$ ./script/console Loading development environment (Rails 2.3.4) >> u = User.find(1) => #<User id: 1, name: "Test", ...> >> u.name.encoding => #<Encoding:ASCII-8BIT> >> require 'lib/mysql_utf8' =>  >> u = User.find(1) => #<User id: 1, name: "Test", ...> >> u.name.encoding => #<Encoding:UTF-8>
Note that if you have BLOB types in MySQL you’ll need to force_encoding back to another type. You could do this in your model.