From 516e9d9f8a159ac92488405333e825e150e59708 Mon Sep 17 00:00:00 2001 From: Rhenium Date: Thu, 16 Jan 2014 06:28:15 +0900 Subject: fix behaviors on error --- app/controllers/errors_controller.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index a9a88bd..3f20494 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -10,19 +10,15 @@ class ErrorsController < ApplicationController when OAuth::Unauthorized # /i/callback redirect_to root_path - when Aclog::Exceptions::TweetNotFound - @status = 404 - @message = t("error.tweet_not_found") - when Aclog::Exceptions::UserNotFound - @status = 404 - @message = t("error.user_not_found") when Aclog::Exceptions::LoginRequired @status = 403 @message = t("error.login_required") when Aclog::Exceptions::OAuthEchoUnauthorized @status = 401 @message = t("error.oauth_echo_unauthorized") - when ActionController::RoutingError + when ActionController::RoutingError, + ActiveRecord::RecordNotFound, + ActionView::MissingTemplate @status = 404 @message = t("error.routing_error") when Aclog::Exceptions::UserNotRegistered @@ -52,9 +48,7 @@ class ErrorsController < ApplicationController end def force_format - if request.format == :html - request.format = (env["REQUEST_PATH"].scan(/\.([A-Za-z]+)$/).flatten.first || :html).to_sym - end + request.format = (env["REQUEST_PATH"].scan(/\.([A-Za-z]+)$/).flatten.first || :html).to_sym unless request.format == :html || request.format == :json request.format = :html -- cgit v1.2.3