0

In my rails application I have upgraded in the past from rails 3.0 to rails 3.1, now I am getting multiple languages stored in my DB and have ran into :

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):

so spanish look like this: "TU SERER QUERIDOS ESTRA\xC3\x83\xC2\xB1AN TU PRECENSIA,"

So what would be a good method to get the data to save as UTF-8? and not kill my views? (I think I only have around 40 of these errors right now, so deleting and reinputing the data is not to bad.

I am also running mysql gem and not mysql2 gem, which I read somewhere, but when trying to install that gem the application blows up. So a easy work around would be deeply appreciated.

Geoff Lanotte
  • 7,490
  • 1
  • 38
  • 50
tspore
  • 1,349
  • 2
  • 11
  • 14

1 Answers1

0

I strongly encourage you to migrate to mysql2. It's not workaround, it's proper solution. Development of mysql gem stopped in 2009 and currently it doesn't handle encoding well. BTW, have you switched from Ruby 1.8 to 1.9 as well? Ruby 1.9 introduces significant changes in string encoding and migrating back to 1.8 might fix your issue. But again – change your gem to mysql2. For a number of reasons.

skalee
  • 12,331
  • 6
  • 55
  • 57
  • Ok I am running 1.9.3 and I will get it to work. The issue I saw with mysql2 is that it hasn't been updated in the last 6 months, so I thought I would ask on what the proper approach would be thank you all for your input. – tspore Jun 15 '12 at 14:18