2009-12-28 3 views
0

제가 작업하고있는 레일 앱의 404 페이지에서 작업 할 때 페이지에서 html로 변경 한 사항을 확인하는 유일한 방법은 실제로 ctrl-C으로 웹 서버를 다시 시작하는 것입니다. 이어서 script/server으로 전화하십시오.여기에서 404.html 페이지를 테스트 할 때마다 레일을 다시 시작해야하는 이유는 무엇입니까?

는 지금까지 내가 말할 수있는, 내가 여기에 development.rb 설정 파일 특히 아무 잘못 볼 수 없습니다 : application_controller.rb에서 나는했습니다, 그래서

# Settings specified here will take precedence over those in config/environment.rb 

# In the development environment your application's code is reloaded on 
# every request. This slows down response time but is perfect for development 
# since you don't have to restart the webserver when you make code changes. 
config.cache_classes = false 

# Log error messages when you accidentally call methods on nil. 
config.whiny_nils = true 

# Show full error reports and disable caching 
config.action_controller.consider_all_requests_local = true 
config.action_view.debug_rjs       = true 
config.action_controller.perform_caching    = false 

# Don't care if the mailer can't send 
config.action_mailer.raise_delivery_errors = false 
config.action_mailer.perform_deliveries = false 

# add rack bug 
# config.middleware.use "Rack::Bug" 

# this disables the caching for comatose, not the rest of the app 
# config.disable_caching = true 

config.action_mailer.default_url_options = { :host => "localhost:3000" } 

config.gem "thoughtbot-factory_girl", 
      :lib => "factory_girl", 
      :source => "http://gems.github.com" 

이 혼자 로컬 오류 페이지를 표시 할 것

# this method allows you to test 404 and 500 pages locally 
alias_method :rescue_action_locally, :rescue_action_in_public 

여기이 한 번 나에게 오류 페이지를 보여줍니다,하지만 미래에 다시로드가 때 자체 HTML 파일의 상태를 보여 있도록 캐시 : 나를 스택 트레이스를보고 중지하려면 rescue_action_in_public 방법에 rescue_action_locally을 별칭 rver가로드되었습니다.

로그 출력은 나에게 어떤 이상한 캐싱 동작을 표시하지 않습니다 - 그 다음 필요에 따라 HTML 페이지를 렌더링, 아무것도 발견하지, 존재하지 않는 자원에 대한 요청을 얻고있다 :

[email protected] ~/RailsApps/annoying_app > script/server --debugger 
    => Booting Mongrel 
    => Rails 2.3.2 application starting on http://0.0.0.0:3000 
    => Debugger enabled 
    => Call with -d to detach 
    => Ctrl-C to shutdown server 
    SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 

    Processing ApplicationController#index (for 127.0.0.1 at 2009-12-28 19:23:27) [GET] 

    ActionController::RoutingError (No route matches "/non-existent-resource" with {:method=>:get}): 

    Rendering /Users/chrisadams/RailsApps/annoying_app/public/404.html (404 Not Found) 

404을. html은 ERB가 전혀없는 정적 인 정적 HTML 페이지입니다.이 정적 HTML 페이지는 페이지 새로 고침 사이에서 변경되지 않습니다.

내가 뭘 잘못하고 있니? 이것은 나를 미치게하고있다!

답변

1

모든 요청이 개발 모드에서도 모든 것이 다시로드되는 것은 아닙니다. 404.html 페이지가 완전히 정적입니까, 아니면 ERB 등으로 실행하고 있습니까?

rescue_from도 현재 요즘 일반적으로 선호되는 방법이되고 있습니다.

+0

왜 그런지 모르겠지만'rescue_from '을 사용하면 이상한 캐싱 문제를 해결 한 것 같습니다. 팁 고마워. –

0

이 방법이 도움이 될지 잘 모르겠지만 환경을 지정하지 않은 경우에도 실수로 environment.rb에서 ENV['RAILS_ENV'] ||= 'production' 줄의 주석 처리를 제거하고 프로덕션 모드에서 내 앱을 시작했습니다.

그럴 수 있습니까?

관련 문제