before_filter中未定义的参数和会话哈希值

时间:2009-05-29 11:32:25

标签: ruby-on-rails ruby debugging ruby-debug

有人知道为什么,在使用ruby-debug作为debugger方法调用before_filter时使用params时,sessionclass MyExampleController < ActionController::Base before_filter :test_hashes def test_hashes pp session pp params #both work as expected.. debugger #calling the debug console end def index #whatever.. end end #the rdb console (rdb:5) pp params NameError Exception: undefined local variable or method 'params' for #<ActionController::Filters::BeforeFilter:0x3eafda0> (rdb:5) pp session NameError Exception: undefined local variable or method 'session' for #<ActionController::Filters::BeforeFilter:0x3eafda0> 哈希未定义?

{{1}}

这是正常行为还是我做错了什么?

2 个答案:

答案 0 :(得分:3)

尝试放b.s.调用调试器之后的行,看看会发生什么。

答案 1 :(得分:0)

不知道为什么它不起作用,但你可以通过controller.params和controller.session获取变量

相关问题