0

When i upload my rails app via SFTP to production server which is running Ubuntu 10.04 LTS all cyrillic characters in my files look like this:

http://dl.dropbox.com/u/347209/chars.png

As you can see, only parts of words are broken. And because of this rails app doesn't start with syntax error.

Also i'm getting errors like

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)
maxt3r
  • 101
  • 5

1 Answers1

0

Turns out ruby 1.9 gets default external encoding from environment variable $LANG. On my Ubuntu the following command outputs US-ASCII for some reason:

ruby -e 'puts Encoding.default_external.name'

So i added the following line to the end of /etc/environment file:

LANG = "en_US.UTF-8"

After that i rebooted the server and everything was ok.

If you don't want to change global locales on your system you can also add "magic comment" to the top of your .rb files to force encoding where needed.

# coding: utf-8 
maxt3r
  • 101
  • 5