Skip to content

Commit dce8b7f

Browse files
Improve rescue_from example [ci-skip]
1 parent 992ead1 commit dce8b7f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

activesupport/lib/active_support/rescuable.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ module ClassMethods
3030
# any.
3131
#
3232
# class ApplicationController < ActionController::Base
33-
# rescue_from User::NotAuthorized, with: :deny_access # self defined exception
34-
# rescue_from ActiveRecord::RecordInvalid, with: :show_errors
33+
# rescue_from User::NotAuthorized, with: :deny_access
34+
# rescue_from ActiveRecord::RecordInvalid, with: :show_record_errors
3535
#
36-
# rescue_from 'MyAppError::Base' do |exception|
37-
# render xml: exception, status: 500
36+
# rescue_from "MyApp::BaseError" do |exception|
37+
# redirect_to root_url, alert: exception.message
3838
# end
3939
#
4040
# private
4141
# def deny_access
42-
# ...
42+
# head :forbidden
4343
# end
4444
#
45-
# def show_errors(exception)
46-
# exception.record.new_record? ? ...
45+
# def show_record_errors(exception)
46+
# redirect_back_or_to root_url, alert: exception.record.errors.full_messages.to_sentence
4747
# end
4848
# end
4949
#
@@ -79,7 +79,7 @@ def rescue_from(*klasses, with: nil, &block)
7979
# Be sure to re-raise unhandled exceptions if this is what you expect.
8080
#
8181
# begin
82-
#
82+
# # ...
8383
# rescue => exception
8484
# rescue_with_handler(exception) || raise
8585
# end

0 commit comments

Comments
 (0)