Gjermund Lunder wrote in post #964821: > Robert K. (or others), If you do have have the exact line for the > enforce coding and in witch erb files to put it I would be happy.
To replicate this error, call: rails -v > Rails 3.0.3 ruby - v > ruby 1.9.2p0 (2010-08-18) [i386-mingw32] Mysql version: 5.1.45-community-log rails new r4_test -d mysql && cd r4_test rails g scaffold post title:string content:string rem:text rake db:create rake db:migrate rails s http://localhost:3000/posts call 'New Post' to all three filends insert e.g. "löwe" or "tomáš" After this I'll get: > incompatible character encodings: UTF-8 and ASCII-8BIT Extracted source (around line #15): 12: 13: <p> 14: <b>Rem:</b> 15: <%= @post.rem %> 16: </p> 17: 18: A monkey work-around -------------------- line 18 in "app\views\posts\index.html.erb" change: <td><%= post.rem.force_encoding('utf-8') %></td> A better work-around -------------------- 1)add among the initializers: class ActiveRecord::Base def force_utf attributes.each {|key, value| value.force_encoding('utf-8') if value.encoding != 'utf-8' if value.kind_of?(String) } end end 2)before first loading or using of a activerecord object in the template (here it is a Post) I call .force_utf e.g. insert line 14 in "app\views\posts\index.html.erb" <% post.force_utf %> Changing InnoDb format of a table to Myisam does not help. It is true, this problem does not appear with sqlite; but I have some reasons to use MySQL. I wonder, MySQL should be the couse of the problem - I have used the same database type and revision and structure under 2.2.2 rails / 1.8 ruby without problems I hope, next revision of ROR (3.0.4?) or mysql2 driver will solve this problem. Attachments: http://www.ruby-forum.com/attachment/5493/r4_test.zip -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

