RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: stefanhendriks
I noticed that in 404 cases the ExceptionWrapper somehow returned 500 (not sure why). When really an exception occured, it would however render a 404 instead of a 500.
In stead of my previous comment, I have used:
status = params[:status] || ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
Also, I figured that simply creating static error pages (even from PROD environment) is not sufficient in Rails 4. The whole reason I am using dynamic pages is because the assets no longer are offered in a non-digest way. Therefor I cannot generate static pages and commit them, as the digest will change per deploy on prod (precompiling assets everytime). A github issue (https://github.com/rails/sprockets-rails/issues/49) has been made a while back about this.
It would be nice if Ryan could elaborate/update this screencast about this issue.
Tried in Rails 4, works fine. Except calling directly to errors/404 (for using the curl stuff). However Mike Henke pointed to the correct solution, at least in Rails 4 I had to remove the action: part. After that it worked fine. Including the status passing it would be:
status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
render request.path[1..-1], status: status_code
Also, just using the dynamic pages would result in my feature specs into a ActionView::MissingTemplate error. Even with config.consider_all_requests_local = false in the test.rb within the environments folder.
config.consider_all_requests_local = false
The only thing that helped me so far was to create static error pages using the (now working) curl command.