1

I have UTF-8 everywhere so why does Page.last.url.encoding return "ASCII-8BIT"?

My database.yml:

development:
  adapter: mysql
  username: root
  encoding: utf8
  database: recipebook

mysql:

CREATE TABLE `pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `recipe_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `html` blob,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
brian
  • 3,344
  • 2
  • 26
  • 35

1 Answers1

1

Which version of mysql gem do you use? 2.8 is not ruby 1.9 encoding-aware. You can monkey patch it using the instructions here. Mysql2 should be encoding-aware, but I'm not sure it works on Rails 2 (which version of rails do you use, by the way?)

Teoulas
  • 2,943
  • 22
  • 27
  • SO question about mysql2: http://stackoverflow.com/questions/3001243/ruby-rails-mysql2-gem-does-somebody-use-this-gem-is-it-stable – Teoulas Nov 03 '10 at 19:06