How to test 500.html in rails development env?

前端 未结 8 1179
悲哀的现实
悲哀的现实 2020-12-14 05:53

I want to test the 500 error pages in my Rails app using the development environment.

I already tried this in config/environments/development.rb:

相关标签:
8条回答
  • 2020-12-14 06:35

    You can either:

    1. access the application using address other than localhost or 127.0.0.1 which rails considers by default to be local requests
    2. Override local_request? in application_controller.rb to something like:
    def local_request?
      false
    end
    

    The second will stop rails treating requests from localhost and 127.0.0.1 as local requests which combined with consider_all_requests_local = false should show you your 500.html page.

    0 讨论(0)
  • 2020-12-14 06:35

    if you just want to force a 500 error to see what it looks like, you can just add this to a view:

    haml example:

    = render :partial => "broken", :status => 500
    
    0 讨论(0)
提交回复
热议问题