Skip to content
Browse files

Be more careful about deducing action_methods

  • Loading branch information...
1 parent fbc6129 commit 165120a606577dd81fe1a267899c4415fe25f1fb @jeremy jeremy committed Aug 6, 2008
Showing with 10 additions and 6 deletions.
  1. +10 −6 actionpack/lib/action_controller/base.rb
View
16 actionpack/lib/action_controller/base.rb
@@ -428,11 +428,7 @@ def controller_path
# By default, all methods defined in ActionController::Base and included modules are hidden.
# More methods can be hidden using <tt>hide_actions</tt>.
def hidden_actions
- unless read_inheritable_attribute(:hidden_actions)
- write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods.map { |m| m.to_s })
- end
-
- read_inheritable_attribute(:hidden_actions)
+ read_inheritable_attribute(:hidden_actions) || write_inheritable_attribute(:hidden_actions, [])
end
# Hide each of the given methods from being callable as actions.
@@ -1234,7 +1230,15 @@ def action_methods
end
def self.action_methods
- @action_methods ||= Set.new(public_instance_methods.map { |m| m.to_s }) - hidden_actions + public_instance_methods(false).map { |m| m.to_s }
+ @action_methods ||=
+ # All public instance methods of this class, including ancestors
+ public_instance_methods(true).map { |m| m.to_s }.to_set -
+ # Except for public instance methods of Base and its ancestors
+ Base.public_instance_methods(true).map { |m| m.to_s } +
+ # Be sure to include shadowed public instance methods of this class
+ public_instance_methods(false).map { |m| m.to_s } -
+ # And always exclude explicitly hidden actions
+ hidden_actions
end
def add_variables_to_assigns

0 comments on commit 165120a

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