Hallo, I face a similar problem, but here mentioned solutions seem to
not work.
When I try to display string with non-ascii chars from a mysql database
in form, sometimes the program stops with the 'incompatible character
encodings: ASCII-8BIT' error. This issue appears only at some fileds in
a table! Configuration of all fields is the same (varchar-string or
memo-text, encoding UTF-8).
For example:
I have record with 4 string fields, all have the same content (the same
word). When I try to display them, the 'incompatible...' error appears.
When I check their '.encoding', I get UTF-8 for three and ASCII-8BIT for
one! Sometimes, when I render this template again and again, two are
ASCII and Two UTF. Strange - not?
I dont know about any difference among these fields configuration.
Yes, .enforce-coding('utf-8') added to all instance in erb file works,
but it is not natty solution.
The same problem appears both at old project transformed from Ruby
1.8/rails 2.2 and at new project creatd in 5minutes via scaffolding in
ruby1,9,2/rails3.0.3.
The patch 'ruby_191_hacks.rb' does not work here, I got the same output
as 'Posted by Heinz Strunk (cojones) on 2010-04-06 11:49'
I have realized, that the template (erb file) must be saved in the same
coding, as the field are (i think the comment about UTF widely mentioned
above says to interpeter, that the file is in UTF coding)
My configuration:
Ruby 1.9.2, Rails 3.0.3 (3.0.1 behaves the same), mysql2 0.2.6 driver
(mysql 2.8.1 makes the same problem, mysql-ruby does not work here - it
misses an UNIX constant), both mysql2 and utf8 set in database.yml,
machine WinXP SP3.
Any idea, how to induce ActiveRecord to provide all the fields in the
UTF-8 encoding?