aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/controller_helper.rb
diff options
context:
space:
mode:
authorLisa Ugray <lisa.ugray@shopify.com>2017-07-14 13:37:31 -0400
committerLisa Ugray <lisa.ugray@shopify.com>2017-07-19 07:54:45 -0400
commit3cb7fe590f2b3cf29c2a32504fb4d24a79559a0b (patch)
tree2d77d30eda8d1c42d2e774c48183f7aa61df55cf /actionview/lib/action_view/helpers/controller_helper.rb
parentd1281cdc2c11ebf26a4e040b02ac1da21f2010a0 (diff)
downloadrails-3cb7fe590f2b3cf29c2a32504fb4d24a79559a0b.tar.gz
rails-3cb7fe590f2b3cf29c2a32504fb4d24a79559a0b.tar.bz2
rails-3cb7fe590f2b3cf29c2a32504fb4d24a79559a0b.zip
Delegate respond_to? in ActionView::Helpers::ControllerHelper
Since methods defined in the controller helper are mostly delegated to the controller, delegate respond_to? as well, so that for example `respond_to?(:params)` behaves as expected.
Diffstat (limited to 'actionview/lib/action_view/helpers/controller_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/controller_helper.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/controller_helper.rb b/actionview/lib/action_view/helpers/controller_helper.rb
index e86cdca4e4..65854e317f 100644
--- a/actionview/lib/action_view/helpers/controller_helper.rb
+++ b/actionview/lib/action_view/helpers/controller_helper.rb
@@ -7,8 +7,11 @@ module ActionView
module ControllerHelper #:nodoc:
attr_internal :controller, :request
- delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers,
- :flash, :action_name, :controller_name, :controller_path, to: :controller
+ CONTROLLER_DELEGATES = [:request_forgery_protection_token, :params,
+ :session, :cookies, :response, :headers, :flash, :action_name,
+ :controller_name, :controller_path]
+
+ delegate *CONTROLLER_DELEGATES, to: :controller
def assign_controller(controller)
if @_controller = controller
@@ -21,6 +24,11 @@ module ActionView
def logger
controller.logger if controller.respond_to?(:logger)
end
+
+ def respond_to?(method_name, include_private = false)
+ return controller.respond_to?(method_name) if CONTROLLER_DELEGATES.include?(method_name.to_sym)
+ super
+ end
end
end
end