diff options
author | Marcel Molina <marcel@vernix.org> | 2006-04-05 04:39:59 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-04-05 04:39:59 +0000 |
commit | 4859b6c09e188462b4d29328c0bb891cd98d8f31 (patch) | |
tree | 80a0e32fc76914ddd127ee1ef9df7a320c655600 /actionpack/lib/action_controller | |
parent | 3d99d33a6456fd6da234635ba55b5bf1ce726c26 (diff) | |
download | rails-4859b6c09e188462b4d29328c0bb891cd98d8f31.tar.gz rails-4859b6c09e188462b4d29328c0bb891cd98d8f31.tar.bz2 rails-4859b6c09e188462b4d29328c0bb891cd98d8f31.zip |
Honor skipping filters conditionally for only certain actions even when the parent class sets that filter to conditionally be executed only for the same actions. Closes #4522.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/filters.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb index 2b260b80d7..1c957e7120 100644 --- a/actionpack/lib/action_controller/filters.rb +++ b/actionpack/lib/action_controller/filters.rb @@ -255,6 +255,7 @@ module ActionController #:nodoc: # just like when you apply the filters. def skip_before_filter(*filters) if conditions = extract_conditions!(filters) + remove_contradicting_conditions!(filters, conditions) conditions[:only], conditions[:except] = conditions[:except], conditions[:only] add_action_conditions(filters, conditions) else @@ -272,6 +273,7 @@ module ActionController #:nodoc: # just like when you apply the filters. def skip_after_filter(*filters) if conditions = extract_conditions!(filters) + remove_contradicting_conditions!(filters, conditions) conditions[:only], conditions[:except] = conditions[:except], conditions[:only] add_action_conditions(filters, conditions) else @@ -332,6 +334,17 @@ module ActionController #:nodoc: def condition_hash(filters, *actions) filters.inject({}) {|hash, filter| hash.merge(filter => actions.flatten.map {|action| action.to_s})} end + + def remove_contradicting_conditions!(filters, conditions) + return unless conditions[:only] + filters.each do |filter| + next unless included_actions_for_filter = included_actions[filter] + [*conditions[:only]].each do |conditional_action| + conditional_action = conditional_action.to_s + included_actions_for_filter.delete(conditional_action) if included_actions_for_filter.include?(conditional_action) + end + end + end end module InstanceMethods # :nodoc: |