| Module | ActionController::Filters::ClassMethods |
| In: |
vendor/rails/actionpack/lib/action_controller/filters.rb
|
The passed filters will be appended to the array of filters that run after actions on this controller are performed.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 461
461: def append_after_filter(*filters, &block)
462: filter_chain.append_filter_to_chain(filters, :after, &block)
463: end
If you append_around_filter A.new, B.new, the filter chain looks like
B#before
A#before
# run the action
A#after
B#after
With around filters which yield to the action block, before and after are the code before and after the yield.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 484
484: def append_around_filter(*filters, &block)
485: filter_chain.append_filter_to_chain(filters, :around, &block)
486: end
The passed filters will be appended to the filter_chain and will execute before the action on this controller is performed.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 446
446: def append_before_filter(*filters, &block)
447: filter_chain.append_filter_to_chain(filters, :before, &block)
448: end
Returns an array of Filter objects for this controller.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 536
536: def filter_chain
537: if chain = read_inheritable_attribute('filter_chain')
538: return chain
539: else
540: write_inheritable_attribute('filter_chain', FilterChain.new)
541: return filter_chain
542: end
543: end
The passed filters will be prepended to the array of filters that run after actions on this controller are performed.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 467
467: def prepend_after_filter(*filters, &block)
468: filter_chain.prepend_filter_to_chain(filters, :after, &block)
469: end
If you prepend_around_filter A.new, B.new, the filter chain looks like:
A#before
B#before
# run the action
B#after
A#after
With around filters which yield to the action block, before and after are the code before and after the yield.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 498
498: def prepend_around_filter(*filters, &block)
499: filter_chain.prepend_filter_to_chain(filters, :around, &block)
500: end
The passed filters will be prepended to the filter_chain and will execute before the action on this controller is performed.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 452
452: def prepend_before_filter(*filters, &block)
453: filter_chain.prepend_filter_to_chain(filters, :before, &block)
454: end
Removes the specified filters from the after filter chain. Note that this only works for skipping method-reference filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out of many sub-controllers need a different hierarchy.
You can control the actions to skip the filter for with the :only and :except options, just like when you apply the filters.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 521
521: def skip_after_filter(*filters)
522: filter_chain.skip_filter_in_chain(*filters, &:after?)
523: end
Removes the specified filters from the before filter chain. Note that this only works for skipping method-reference filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out of many sub-controllers need a different hierarchy.
You can control the actions to skip the filter for with the :only and :except options, just like when you apply the filters.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 511
511: def skip_before_filter(*filters)
512: filter_chain.skip_filter_in_chain(*filters, &:before?)
513: end
Removes the specified filters from the filter chain. This only works for method reference (symbol) filters, not procs. This method is different from skip_after_filter and skip_before_filter in that it will match any before, after or yielding around filter.
You can control the actions to skip the filter for with the :only and :except options, just like when you apply the filters.
# File vendor/rails/actionpack/lib/action_controller/filters.rb, line 531
531: def skip_filter(*filters)
532: filter_chain.skip_filter_in_chain(*filters)
533: end