Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails app gives error "can not load translations from {ru.yml path} expected it to return a hash, but does not"

My application works fine locally, but when i'm installing it to production server, i get the following error running rails server and requesting page:

ActionView::Template::Error (can not load translations from {app}/config/locales/ru.yml, expected it to return a hash, but does not).

I have YAML translation ru.yml:

ru:
  clients:
    index: 
      title: Список клиентов

And error happens while calling, ex:

%h1=t '.title'

My development machine is running Mac OS X ML

Production server is CentOS 6 with rvm and libyaml installed.

Both servers are on Ruby 1.9.2p320 and Rails 3.2.8

like image 794
lich Avatar asked Sep 25 '12 12:09

lich


2 Answers

Operation YAML.load(File.open('config/locales/ru.yml')) gave me error in one of lines.

I added quotes: default: '%d.%m.%Y %H:%M' and got a hash. Problem is solved.

like image 148
lich Avatar answered Nov 08 '22 14:11

lich


The problem is about using psych YAML engine which can not parse strings with % sign and generates SyntaxError exception.

Use syck engine instead. Add the following code to the end of your config/boot.rb file

YAML::ENGINE.yamler = 'syck'

hint: syck requires Ruby version >= 2.0.0.

like image 24
fey Avatar answered Nov 08 '22 14:11

fey