aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller
diff options
context:
space:
mode:
authorJesse Storimer <jstorimer@gmail.com>2010-08-26 22:18:35 -0400
committerJosé Valim <jose.valim@gmail.com>2010-08-28 18:07:01 -0300
commit730af4896358d9125dbd7b8384d66460ae839a45 (patch)
treecc10bba2c573eebdc415c655ca0524aa2154990f /actionpack/lib/abstract_controller
parent83f4507cf153ea6081dd70326f5f3a0331cc167e (diff)
downloadrails-730af4896358d9125dbd7b8384d66460ae839a45.tar.gz
rails-730af4896358d9125dbd7b8384d66460ae839a45.tar.bz2
rails-730af4896358d9125dbd7b8384d66460ae839a45.zip
Ensure that inherited helper_methods are available after calling clear_helpers [#5348 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r--actionpack/lib/abstract_controller/helpers.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb
index a0ce121ade..20f8601a8e 100644
--- a/actionpack/lib/abstract_controller/helpers.rb
+++ b/actionpack/lib/abstract_controller/helpers.rb
@@ -9,6 +9,9 @@ module AbstractController
included do
class_attribute :_helpers
self._helpers = Module.new
+
+ class_attribute :_helper_methods
+ self._helper_methods = Array.new
end
module ClassMethods
@@ -43,7 +46,10 @@ module AbstractController
# * <tt>method[, method]</tt> - A name or names of a method on the controller
# to be made available on the view.
def helper_method(*meths)
- meths.flatten.each do |meth|
+ meths.flatten!
+ self._helper_methods += meths
+
+ meths.each do |meth|
_helpers.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
def #{meth}(*args, &blk)
controller.send(%(#{meth}), *args, &blk)
@@ -98,7 +104,11 @@ module AbstractController
# Clears up all existing helpers in this class, only keeping the helper
# with the same name as this class.
def clear_helpers
+ inherited_helper_methods = _helper_methods
self._helpers = Module.new
+ self._helper_methods = Array.new
+
+ inherited_helper_methods.each { |meth| helper_method meth }
default_helper_module! unless anonymous?
end