Utf8 problem

Hello.
I’ve started to study ruby and rails.

I added string to the model:
validates_length_of :first_name, :within => 3…64, :too_long =>
‘long’, :too_short => ‘short’
It works.

I changed error messges (I need to use russian words in it):
validates_length_of :first_name, :within => 3…64, :too_long =>
‘Длинное’, :too_short => ‘Короткое’
It doesn’t work. The error is:
… app/models/user.rb:3: invalid multibyte char (US-ASCII) …

Tried to find decision with google. Tried to use monkey patches:

I dont’t now if my using was correct: I just created 3 files
(patch.rb, fix_params.rb, fix_renderable.rb) in the folder config/
initializers - I didn’t require it anywhere (I think, that it
happends automatically).
Error changed to:
… incompatible character encodings: ASCII-8BIT and UTF-8 …
This error is in ruby, not in rails:
D:/WebProgramming/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/
lib/active_support/core_ext/string/output_safety.rb:34:in `concat’

My configuration:
ruby 1.9.1
rails 2.3.5
Windows XP
Redactor is Aptana - it uses utf8 as default

What have I to do to russian words become to work (utf8)? I want to
find decision for Windows Ruby 1.9.1

kouzma wrote:

Hello.
I’ve started to study ruby and rails.

I added string to the model:
validates_length_of :first_name, :within => 3…64, :too_long =>
‘long’, :too_short => ‘short’
It works.

I changed error messges (I need to use russian words in it):
validates_length_of :first_name, :within => 3…64, :too_long =>
‘Длинное’, :too_short => ‘Короткое’
It doesn’t work. The error is:
… app/models/user.rb:3: invalid multibyte char (US-ASCII) …

Tried to find decision with google. Tried to use monkey patches:
ruby_191_hacks.rb · GitHub
I dont’t now if my using was correct: I just created 3 files
(patch.rb, fix_params.rb, fix_renderable.rb) in the folder config/
initializers - I didn’t require it anywhere (I think, that it
happends automatically).
Error changed to:
… incompatible character encodings: ASCII-8BIT and UTF-8 …
This error is in ruby, not in rails:
D:/WebProgramming/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/
lib/active_support/core_ext/string/output_safety.rb:34:in `concat’

My configuration:
ruby 1.9.1
rails 2.3.5
Windows XP
Redactor is Aptana - it uses utf8 as default

What have I to do to russian words become to work (utf8)? I want to
find decision for Windows Ruby 1.9.1

Have you tried putting

encoding: utf-8

as the first line of that model’s file?

http://blog.nuclearsquid.com/writings/ruby-1-9-encodings and
http://blog.grayproductions.net/articles/ruby_19s_string are good
articles to help beginning to understand Ruby 1.9’s encoding
agnosticism.