2009-05-29 2 views
3

before_filter이라는 메서드에서 debugger을 호출하여 ruby-debug를 사용할 때 paramssession 해시가 정의되지 않은 이유는 누구나 알 수 있습니까?before_filter에서 정의되지 않은 params와 세션 해시

class 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> 

이 정상적인 동작입니까 또는 내가 잘못하고 있습니까?

답변

3

가 학사 학위를 취득 퍼팅 시도 controller.params 및 controller.session을 통해 변수를 얻을 수있는 이유 디버거를 호출 한 후 어떤 행이 발생하는지 확인하십시오.

+0

A b.s. 선..? 나는 이해가되지 않을까 두렵다. – andi

+0

1과 같은 숫자 리터럴. b.s. 말도 안돼. – jshen

+0

나는 그 학사를 말하는 줄 알았지 만, 어떻게하면 좋은 일을 할 수 있는지 보지 못했습니다. :) 그러나 나는 그것을 시도하고 그것은 효과가! 나는 그것을 믿을 수 없다! 어떻게 왔어?! 합리적인 설명이 있습니까? 이거 버그 야? – andi

0

어떤 생각이 작동하지 않습니다,하지만 당신은