Skip to content
Browse files

Merge pull request #12622 from timsly/helpers-from-outside

pass app config to controller helper proxy
  • Loading branch information...
2 parents 783527f + 719f1d6 commit 80e90b0bd0b0cd50a186e314034d68182c045765 @guilleiguaran guilleiguaran committed Oct 23, 2013
Showing with 11 additions and 1 deletion.
  1. +5 −1 actionpack/lib/action_controller/metal/helpers.rb
  2. +6 −0 actionpack/test/controller/helper_test.rb
View
6 actionpack/lib/action_controller/metal/helpers.rb
@@ -73,7 +73,11 @@ def helper_attr(*attrs)
# Provides a proxy to access helpers methods from outside the view.
def helpers
- @helper_proxy ||= ActionView::Base.new.extend(_helpers)
+ @helper_proxy ||= begin
+ proxy = ActionView::Base.new
+ proxy.config = config.inheritable_copy
+ proxy.extend(_helpers)
+ end
end
# Overwrite modules_for_helpers to accept :all as argument, which loads
View
6 actionpack/test/controller/helper_test.rb
@@ -201,6 +201,12 @@ def test_helper_proxy
# fun/pdf_helper.rb
assert methods.include?(:foobar)
end
+
+ def test_helper_proxy_config
+ AllHelpersController.config.my_var = 'smth'
+
+ assert_equal 'smth', AllHelpersController.helpers.config.my_var
+ end
private
def expected_helper_methods

0 comments on commit 80e90b0

Please sign in to comment.
Something went wrong with that request. Please try again.