diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7526476..78c312f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,11 +2,11 @@ class NotFound < StandardError; end class ApplicationController < ActionController::Base protect_from_forgery - rescue_from(ActiveRecord::RecordNotFound) { render 'exceptions/not_found' } class Unauthorized < Exception; end class Forbidden < Exception; end + rescue_from ActiveRecord::RecordNotFound, :with => :not_found rescue_from Unauthorized, :with => :unauthorized rescue_from Forbidden, :with => :forbidden @@ -66,4 +66,16 @@ class ApplicationController < ActionController::Base redirect_to login_path, :notice => "Please login" end end + + def not_found + respond_to do |format| + format.any do + render :text => 'Requested resource not found', :status => 404 + end + + format.html do + render 'application/not_found', :status => 404 + end + end + end end diff --git a/app/controllers/exceptions_controller.rb b/app/controllers/exceptions_controller.rb deleted file mode 100644 index 433617a..0000000 --- a/app/controllers/exceptions_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ExceptionsController < ApplicationController - - def not_found - respond_to do |format| - format.any do - render :text => 'Requested resource not found', :status => 404 - end - - format.html do - render :status => 404 - end - end - end - -end diff --git a/app/views/exceptions/not_found.html.erb b/app/views/application/not_found.html.erb similarity index 100% rename from app/views/exceptions/not_found.html.erb rename to app/views/application/not_found.html.erb diff --git a/spec/controllers/exceptions_controller_spec.rb b/spec/controllers/exceptions_controller_spec.rb deleted file mode 100644 index bac74fa..0000000 --- a/spec/controllers/exceptions_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe ExceptionsController do - -end