Search code examples
ruby-on-rails-3localethin

Thin throws ArgumentError when processing a t() helper in a view


When starting my application with the standard WEBrick server it works ok (Not throwing any errors), but when starting it with Thin it gives me an error:

ArgumentError in Machine#index

Showing /home/mika/projects/vaalikone/app/views/questions/_detail_box.haml where line #4 raised: 

syntax error on line 6, col 2: `  register_information: "Rekisteriseloste"'

Extracted source (around line #4):

1: .detail_box
2:   %table
3:     %tr
4:       %td= t("question.user")
5:       %td= question.user.full_name
6:     %tr
7:       %td= t("question.created_at")

And the end of the full stack trace:

/home/mika/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/syck.rb:135:in `load'
/home/mika/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/syck.rb:135:in `load'
/home/mika/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/syck.rb:146:in `block in load_file'
/home/mika/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/syck.rb:145:in `open'
/home/mika/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/syck.rb:145:in `load_file'
i18n (0.5.0) lib/i18n/backend/base.rb:170:in `load_yml'
i18n (0.5.0) lib/i18n/backend/base.rb:156:in `load_file'
i18n (0.5.0) lib/i18n/backend/base.rb:15:in `block in load_translations'
i18n (0.5.0) lib/i18n/backend/base.rb:15:in `each'
i18n (0.5.0) lib/i18n/backend/base.rb:15:in `load_translations'
i18n (0.5.0) lib/i18n/backend/simple.rb:55:in `init_translations'
i18n (0.5.0) lib/i18n/backend/simple.rb:69:in `lookup'
i18n (0.5.0) lib/i18n/backend/base.rb:26:in `translate'
i18n (0.5.0) lib/i18n.rb:155:in `translate'
actionpack (3.0.7) lib/action_view/helpers/translation_helper.rb:48:in `translate'
app/views/questions/_detail_box.haml:4:in `_app_views_questions__detail_box_haml___1037386747_92326130__348576359'

I'm absolutely stunned. Thin is complaining about my locale file but WEBrick is not. The beginning of my locale file is below. Does anyone see anything strange in it?

fi:
  login:        "Kirjaudu sisään"
  logout:       "Kirjaudu ulos"
  register:     "Rekisteröidy"
  edit_registration: "Muokkaa tietojasi"
  terms:        "Käyttöehdot"
  register_information: "Rekisteriseloste"
  show:         "Näytä"
  edit:         "Muokkaa"

I guess the error is not so much related with the locale file but something else. If I move the 6th row in the locale file down a couple of lines Thin starts to complain about the row which moves to the 6th row from the 7th row.

Does someone have an idea what is the problem?


Solution

  • Managed to solve this issue by just rewriting parts of my fi.yml locale file around the lines which were triggering the errors. I wasn't able to find any general rule for the error. If the server threw an error for line 34 I rewrote lines 33 and 34. This way I was able to get a working fi.yml file which is not currently throwing any errors.

    At some point I suspected that Thin doesn't like the tabs which I had for keeping the file nice and readable. But in the end it wasn't the reason for errors. You can have tabs in the file, but sometimes adding a tab between the key and the string made Thin to throw error.

    My new fi.yml file differs from the old one only for the white space. In my new fi.yml there is less white space and considerably less tabs, and now it works.

    How weird is that!

    One thing that could have something to do with this is that I added the rails.vim script to my vim around the time of moving to use Thin. Rails.vim changed the tab button to add two spaces instead of a tab character.