#23: return json response at RoutingError
This commit is contained in:
parent
b8a02299fd
commit
f15be4b92a
|
@ -18,10 +18,9 @@ class ApplicationController < ActionController::Base
|
|||
helper_method :get_owner
|
||||
|
||||
unless Rails.env.development?
|
||||
|
||||
rescue_from Exception, :with => :render_500
|
||||
rescue_from ActiveRecord::RecordNotFound,
|
||||
ActionController::RoutingError,
|
||||
# ActionController::RoutingError, # see: config/routes.rb:<last line>
|
||||
ActionController::UnknownController,
|
||||
AbstractController::ActionNotFound, :with => :render_404
|
||||
end
|
||||
|
@ -32,12 +31,13 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
rescue_from Grit::NoSuchPathError, :with => :not_found
|
||||
|
||||
protected
|
||||
|
||||
def render_404
|
||||
render_error 404
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def render_500(e)
|
||||
#check for exceptions Airbrake ignores by default and exclude them from manual Airbrake notification
|
||||
if Rails.env.production? && !AIRBRAKE_IGNORE.include?(e.class)
|
||||
|
|
|
@ -343,4 +343,9 @@ Rosa::Application.routes.draw do
|
|||
get '/' => 'groups/profile#show', :as => :group
|
||||
end
|
||||
end
|
||||
|
||||
# As of Rails 3.0.1, using rescue_from in your ApplicationController to
|
||||
# recover from a routing error is broken!
|
||||
# see: https://rails.lighthouseapp.com/projects/8994/tickets/4444-can-no-longer-rescue_from-actioncontrollerroutingerror
|
||||
match '*a', :to => 'application#render_404'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue