From 0b01cf035bb7c8048e9d69e59a0fc8176e4fb06c Mon Sep 17 00:00:00 2001 From: rhenium Date: Sat, 18 May 2013 20:16:52 +0900 Subject: improve behavior when unknown format --- app/controllers/errors_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/controllers/errors_controller.rb') diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 1755e05..e1d5dcf 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -1,5 +1,7 @@ class ErrorsController < ApplicationController layout "index" + skip_before_filter :check_format + before_filter :force_format def render_error @exception = env["action_dispatch.exception"] @@ -28,4 +30,11 @@ class ErrorsController < ApplicationController render "error", status: 500 end end + + private + def force_format + unless [:json, :html].include?(request.format.to_sym) + request.format = "html" + end + end end -- cgit v1.2.3