2012-09-13 5 views
42

레일에 미니 프로파일 러를 사용하고 있습니다 만 일부 코딩 세션에서 특히 다른 클라이언트 측 코드를 많이 사용하고있는 상황에서 문제가 발생합니다. (주로 내 클라이언트 측 디버깅 도구 네트워크 그래프 등)Rack-Mini-Profiler를 일시적으로 사용하지 않도록 설정하는 방법은 무엇입니까?

필자는 before 필터를 사용하지 않으려 고합니다.이 필터는 사용자에게 프로필을 볼 수있는 권한이 있는지를 확인하는 역할을하지만 "인증을 취소합니다 "나를 위해 아무 것도하지 않는 것 같습니다. 또한 설정 "랙 :: MiniProfiler.config.authorization_mode"가 알고 있지만, 나는 가능한 설정이 무엇인지에 문서를 찾을 수 있으며, 표시되지

def miniprofiler 
off = true 
if off || !current_user 
    Rack::MiniProfiler.deauthorize_request 
    return 
elsif current_user.role_symbols.include?(:view_page_profiles)  
    Rack::MiniProfiler.authorize_request 
    return 
end 
Rack::MiniProfiler.deauthorize_request 
end 

: 여기로 불리는 내 코드는 필터 전에이다 그것은 코드에서 사용 되었습니까? 지금 당장은 allow_all이라고 말하지만 allow_none은 아무 것도하지 않습니다.

dev 환경 파일에 값을 임시로 설정하고 서버를 다시 시작해도 내 목적을 달성 할 수 있습니다.

답변

78

받기 최신 유형 :

당신은 모든 옵션에 대한 ?pp=help를 참조 형에게

http://mysite.com?pp=enable

을 완료

http://mysite.com?pp=disable

:

 
Append the following to your query string: 

    pp=help : display this screen 
    pp=env : display the rack environment 
    pp=skip : skip mini profiler for this request 
    pp=no-backtrace : don't collect stack traces from all the SQL executed (sticky, use pp=normal-backtrace to enable) 
    pp=normal-backtrace (*) : collect stack traces from all the SQL executed and filter normally 
    pp=full-backtrace : enable full backtraces for SQL executed (use pp=normal-backtrace to disable) 
    pp=sample : sample stack traces and return a report isolating heavy usage (experimental works best with the stacktrace gem) 
    pp=disable : disable profiling for this session 
    pp=enable : enable profiling for this session (if previously disabled) 
    pp=profile-gc: perform gc profiling on this request, analyzes ObjectSpace generated by request (ruby 1.9.3 only) 
    pp=profile-gc-time: perform built-in gc profiling on this request (ruby 1.9.3 only) 
+0

우수! Sam을 추가해 주셔서 감사합니다! –

+0

위대한 작품! 다시 한번 감사드립니다. –

+0

@DaveSanders 걱정하지 마시고 http://community.miniprofiler.com에서 기능 요청 등을 언제든지 할 수 있습니다. –

21

을 또한 수 토글하려면 Alt+p을 사용하십시오. before_filter를 추가, 응용 프로그램 컨트롤러에서 다음

Rack::MiniProfiler.config.pre_authorize_cb = lambda {|env| ENV['RACK_MINI_PROFILER'] == 'on'} 

: 당신은 프로파일이 처음 비활성화 한 다음 필요에 활성화되도록하려면

+0

'start_hidden' 옵션을 사용할 때 특히 유용합니다 !! – Eero

2

... 같은 초기화 파일에 사전 승인 콜백을 추가 그

before_filter :activate_profiler 
def activate_profiler 
    ENV['RACK_MINI_PROFILER'] = 'on' if params['pp'] 
    ENV['RACK_MINI_PROFILER'] = 'off' if params['pp'] == 'disabled' 
end 

환경이 RACK_MINI_PROFILER 처음에 설정되지 않습니다 쪽의 PARAM을 찾습니다,하지만 당신은 전원을 켜하려는 경우, 당신은? 당신의 URL에 사용할 쪽을 = 압정 수 있습니다. 그런 다음 나중에 다시 비활성화 할 수 있습니다 (pp = disabled는 현재 세션에서만 해제되지만 ENV 변수를 off로 설정하면 강제로 다시 강제로 종료 할 때까지 완전히 비활성화됩니다).

관련 문제