Merge pull request #27 from abf/rosa-build:23-html-page-for-json-request

#23: Return html page for JSON request
This commit is contained in:
warpc 2013-03-18 19:20:24 +04:00
commit f8ace015dc
2 changed files with 8 additions and 3 deletions

View File

@ -18,10 +18,9 @@ class ApplicationController < ActionController::Base
helper_method :get_owner helper_method :get_owner
unless Rails.env.development? unless Rails.env.development?
rescue_from Exception, :with => :render_500 rescue_from Exception, :with => :render_500
rescue_from ActiveRecord::RecordNotFound, rescue_from ActiveRecord::RecordNotFound,
ActionController::RoutingError, # ActionController::RoutingError, # see: config/routes.rb:<last line>
ActionController::UnknownController, ActionController::UnknownController,
AbstractController::ActionNotFound, :with => :render_404 AbstractController::ActionNotFound, :with => :render_404
end end
@ -32,12 +31,13 @@ class ApplicationController < ActionController::Base
rescue_from Grit::NoSuchPathError, :with => :not_found rescue_from Grit::NoSuchPathError, :with => :not_found
protected
def render_404 def render_404
render_error 404 render_error 404
end end
protected
def render_500(e) def render_500(e)
#check for exceptions Airbrake ignores by default and exclude them from manual Airbrake notification #check for exceptions Airbrake ignores by default and exclude them from manual Airbrake notification
if Rails.env.production? && !AIRBRAKE_IGNORE.include?(e.class) if Rails.env.production? && !AIRBRAKE_IGNORE.include?(e.class)

View File

@ -343,4 +343,9 @@ Rosa::Application.routes.draw do
get '/' => 'groups/profile#show', :as => :group get '/' => 'groups/profile#show', :as => :group
end end
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 end