« `gem_original_require': no such file to load -- ./boot | メイン | ショートブレッド »

Ruby-GetText-Packageで The error occurred while evaluating nil.[]

Ruby-GetText-Packageを導入したら、

/!\ FAILSAFE /!\  Fri Mar 14 19:36:24 +0900 2008
  Status: 500 Internal Server Error
  You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
    /usr/lib/ruby/1.8/cgi.rb:1165:in `[]'

というエラーが出るようになりました。

gettextでinternal server error - cracchoの日記」経由で「Using ruby-gettext with Edge Rails」を見て、解決。

次のコードを「config/environment.rb」の最後にでも追加する。

class CGI
  module QueryExtension
    alias index_without_fix :[]
    def [] (key)
      return nil unless @params[key]
      index_without_fix(key)
    end
  end
end

原因は、Rubyのバグ。
Ruby 1.8.6では修正されているそうです。

トラックバック

このエントリーのトラックバックURL:
http://www.gesource.jp/mt/mt-tb.cgi/723

コメントを投稿

(いままで、ここでコメントしたことがないときは、コメントを表示する前にこのブログのオーナーの承認が必要になることがあります。承認されるまではコメントは表示されません。そのときはしばらく待ってください。)

About

2008年03月14日 19:41に投稿されたエントリーのページです。

ひとつ前の投稿は「`gem_original_require': no such file to load -- ./boot」です。

次の投稿は「ショートブレッド」です。

他にも多くのエントリーがあります。メインページアーカイブページも見てください。

Powered by
Movable Type 3.35