aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorArthur Nogueira Neves <github@arthurnn.com>2016-05-05 17:12:25 -0500
committerArthur Nogueira Neves <github@arthurnn.com>2016-05-05 17:12:25 -0500
commit58a221278897a66bf8b9c909389da40ac2c5e534 (patch)
tree72d117720d93e0cb2ae126b9c697b040562689bd /actionpack/lib
parent1949412a868ccf5addc12b7569f6ebbf4b6488e4 (diff)
parent541a51ecf8ee04f956b7d8efb13935640aa831ce (diff)
downloadrails-58a221278897a66bf8b9c909389da40ac2c5e534.tar.gz
rails-58a221278897a66bf8b9c909389da40ac2c5e534.tar.bz2
rails-58a221278897a66bf8b9c909389da40ac2c5e534.zip
Merge pull request #24866 from rafaelfranca/actionview-helpers
Implement helpers proxy in controller instance level
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb4
-rw-r--r--actionpack/lib/action_controller/base.rb7
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb7
3 files changed, 11 insertions, 7 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 9f192c54f7..a6fb0dbe1d 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -60,9 +60,7 @@ module AbstractController
end
DEFAULT_PROTECTED_INSTANCE_VARIABLES = Set.new %i(
- @_action_name @_response_body @_formats @_prefixes @_config
- @_view_context_class @_view_renderer @_lookup_context
- @_routes @_db_runtime
+ @_action_name @_response_body @_formats @_prefixes
)
# This method should return a hash with assigns.
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 56a8d2e5f4..d546d7260c 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -251,9 +251,10 @@ module ActionController
setup_renderer!
# Define some internal variables that should not be propagated to the view.
- PROTECTED_IVARS = AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES + [
- :@_params, :@_response, :@_request,
- :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout ]
+ PROTECTED_IVARS = AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES + %i(
+ @_params @_response @_request @_config @_url_options @_action_has_layout @_view_context_class
+ @_view_renderer @_lookup_context @_routes @_view_runtime @_db_runtime @_helper_proxy
+ )
def _protected_ivars # :nodoc:
PROTECTED_IVARS
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index d3853e2e83..22493dea50 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -5,7 +5,7 @@ module ActionController
#
# In addition to using the standard template helpers provided, creating custom helpers to
# extract complicated logic or reusable functionality is strongly encouraged. By default, each controller
- # will include all helpers. These helpers are only accessible on the controller through <tt>.helpers</tt>
+ # will include all helpers. These helpers are only accessible on the controller through <tt>#helpers</tt>
#
# In previous versions of \Rails the controller will include a helper which
# matches the name of the controller, e.g., <tt>MyController</tt> will automatically
@@ -113,5 +113,10 @@ module ActionController
all_helpers_from_path(helpers_path)
end
end
+
+ # Provides a proxy to access helpers methods from outside the view.
+ def helpers
+ @_helper_proxy ||= view_context
+ end
end
end