From ernesto.jimenez at negonation.com Mon May 28 09:36:18 2007 From: ernesto.jimenez at negonation.com (=?UTF-8?Q?Ernesto_Jim=C3=A9nez_Caballero?=) Date: Mon, 28 May 2007 16:36:18 +0300 Subject: [gettext-u-en] Problem with gettext 1.9.0 and RESTful rails app Message-ID: <79665d7b0705280636p4c8fae75o4b0b6e8ff4efaf7f@mail.gmail.com> Hello, I'm developing an XML API in a Rails app and I was experiencing a problem with gettext 1.9.0. The XML API was working perfectly, but from time to time I noticed persistent 500 errors from the server. The problem came to be that when have initiated the server (no matter if it's mongrel, or webrick) you cannot do an XML request until you have done an HTML request, until you do the xml request yo get the following error: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] /opt/local/lib/ruby/1.8/cgi.rb:1164:in `[]' /opt/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/locale_cgi.rb:26:in `system' /opt/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/locale.rb:88:in `system' /opt/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/locale.rb:96:in `default' /opt/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/rails.rb:259:in `render_file' [...] The problem is that until you do the first HTML request to the server cgi.params is empty and cgi_["lang"] fails. I have fixed this problem checking if params is empty in locale_cgi.rb Patch and modified file are attached, if you need anything else contact me. Thank you for the great gem :) -- Ernesto Jim?nez Caballero erjica at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: locale_cgi.rb Type: application/octet-stream Size: 2579 bytes Desc: not available Url : http://rubyforge.org/pipermail/gettext-users-en/attachments/20070528/6ba75df7/attachment-0002.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: locale_cgi_empty_params.patch Type: application/octet-stream Size: 532 bytes Desc: not available Url : http://rubyforge.org/pipermail/gettext-users-en/attachments/20070528/6ba75df7/attachment-0003.obj