Ruby 1.9, Rails 2.3.9 and unicode characters in the database view and erb, anyway no?

I have a Rails application running on Rails 2.3.9. It works great with ruby ​​1.8.7. Now I am testing it with ruby ​​1.9.2.

The application loads until I try to load a page based on a Unicode string. Then I get the notorious coding error:

ActionView :: TemplateError (incompatible character encodings: UTF-8 and ASCII-8BIT) ...

It seems like the problem is that I am getting some rows from the database as ASCII-8BIT.

I know that Rails 3 works with ruby ​​1.9 and unicode perfectly. I wonder if the backup solution was equal to 2.3.

So, is there a way to get Unicode 2.3.9 rail applications running under ruby ​​1.9?

+3
source share
2 answers

So, I went ahead and wrote a plugin that fixes two main problems that cause encoding problems:

  • ActiveRecord Models
  • Built-in Rails Helpers

See the UnicodeOverride Plugin on GitHub .

+3
source

If you are using mysql, use this instead of gem http://github.com/tmtm/ruby-mysql. Leave mysql as the database adapter in the database.yml file.

We run ruby ​​1.9.2-rc1 with rails 2.3.8, and this solved the problem of incompatible character encoding.

+1
source

Source: https://habr.com/ru/post/1754018/


All Articles