Skip to content

Commit dcbfe09

Browse files
authored
Merge pull request rails#54191 from wt-l00/fix_action_controller_overview_document
Fix `ActionDurationCallback.around` in action_controller_overview.md [ci-skip]
2 parents 07481ac + dfaf4b1 commit dcbfe09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

guides/source/action_controller_overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,19 +1157,19 @@ class ApplicationController < ActionController::Base
11571157
end
11581158
11591159
class ActionDurationCallback
1160-
def self.around(controller, action)
1160+
def self.around(controller)
11611161
start_time = Time.now
1162-
yield # This executes the action
1162+
yield # This executes the action
11631163
end_time = Time.now
11641164
11651165
duration = end_time - start_time
1166-
Rails.logger.info "Action #{action} from controller #{controller} took #{duration.round(2)} seconds to execute."
1166+
Rails.logger.info "Action #{controller.action_name} from controller #{controller.controller_name} took #{duration.round(2)} seconds to execute."
11671167
end
11681168
end
11691169
```
11701170

11711171
In above example, the `ActionDurationCallback`'s method is not run in the scope
1172-
of the controller but gets `controller` and `action` as an argument.
1172+
of the controller but gets `controller` as an argument.
11731173

11741174
In general, the class being used for a `*_action` callback must implement a
11751175
method with the same name as the action callback. So for the `before_action`

0 commit comments

Comments
 (0)