Rack获取基于会话的cookie时出错

时间:2012-01-24 21:29:43

标签: ruby sinatra rack thin

我的网络应用程序使用的是Rack 1.4.0,Sinatra v1.2.6,Thin v1.2.11,Ruby v1.9.2p180

导航到某个页面我在日志中收到此错误:

TypeError - can't convert nil into String:
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `hexdigest'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `generate_hmac'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:109:in `unpacked_cookie_data'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:99:in `extract_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:262:in `current_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:268:in `session_exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:107:in `exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:122:in `load_for_read!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:59:in `[]'
 /var/www/phrogz.net/routes/test.rb:8:in `logged_in?'

test.rb第8行中的代码是:

session[ :foo ] == "BAR"

有关升级/降级以解决此问题的任何建议吗?

1 个答案:

答案 0 :(得分:2)

看起来你遇到了this issue。修复程序在Rack 1.4.1中,因此只需升级即可修复它。