Reputation: 4511
i use rails 2.3.9 with ruby 1.9.2 and when i trying to update my model with some russian letters i have error in unicorn log:
Error during failsafe response: incompatible character encodings: UTF-8 and ASCII-8BIT
Read error: #<NoMethodError: undefined method `[]' for nil:NilClass>
trace look like this:
/home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:521:in
process_client' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:594:in
block in worker_loop' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:592:ineach' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:592:in
worker_loop' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:482:inblock (2 levels) in spawn_missing_workers' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:479:in
fork' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:479:inblock in spawn_missing_workers' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:475:in
each' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:475:inspawn_missing_workers' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:489:in
maintain_worker_count' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn/http_server.rb:299:injoin' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/lib/unicorn.rb:13:in
run' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/gems/unicorn-3.0.1/bin/unicorn_rails:208:in<top (required)>' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/bin/unicorn_rails:19:in
load' /home/rbdev/.rvm/gems/ruby-1.9.2-p0@rails2/bin/unicorn_rails:19:in `'
so, i can't detirminate the problem, the only thing i know - what problem in russia text ( when i update model with english letters - all is ok. what i can do ? (
Upvotes: 1
Views: 1853
Reputation: 444
you can use gem "russian" (gem is based on l18n) https://github.com/yaroslav/russian in model (instead of russian letters): Russian::translate(:some_word)
in config file (must be encoded in UTF-8): ru: some_word: 'это строка с русскими буквами (this is string with russian letters)'
Upvotes: 0
Reputation: 40760
I answered this one here, with a script. Why are all strings ASCII-8BIT after I upgraded to Rails 3?
You need
# coding: UTF-8
at the top of your files, with ruby 1.9. If that doesn't help, it might be your external dependency, such as DB.
Upvotes: 1
Reputation: 719
You should ensure that your editor saves files in UTF-8. ASCII afaik is the first part of any charset. That should be the reason you don't get any errors when you leave out the russian chars.
Upvotes: 1