Module: RailsAnnoying::ActionController::ClassMethods
- Defined in:
- lib/rails-annoying/action_controller/base.rb
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #render_csrf(exception) ⇒ Object
- #render_error(exception) ⇒ Object
- #render_not_found(exception) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
:nodoc:
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails-annoying/action_controller/base.rb', line 18 def self.included(klass) klass.class_eval do # Rescue exceptions with custom error pages in production unless Rails.application.config.consider_all_requests_local rescue_from ::Exception, :with => :render_error # Generic error (500, etc.) rescue_from ::ActionController::InvalidAuthenticityToken, :with => :render_csrf rescue_from ::ActiveRecord::RecordNotFound, :with => :render_not_found rescue_from ::ActionController::RoutingError, :with => :render_not_found rescue_from ::ActionController::UnknownController, :with => :render_not_found rescue_from ::ActionController::UnknownAction, :with => :render_not_found end extend ClassMethods end end |
Instance Method Details
#render_csrf(exception) ⇒ Object
35 36 37 38 39 |
# File 'lib/rails-annoying/action_controller/base.rb', line 35 def render_csrf(exception) logger.info(exception) render "/errors/csrf", :status => 403 end |
#render_error(exception) ⇒ Object
41 42 43 44 45 |
# File 'lib/rails-annoying/action_controller/base.rb', line 41 def render_error(exception) logger.error(exception) render "/errors/500", :status => 500 end |
#render_not_found(exception) ⇒ Object
47 48 49 50 51 |
# File 'lib/rails-annoying/action_controller/base.rb', line 47 def render_not_found(exception) logger.info(exception) render "/errors/404", :status => 404 end |