Skip to content

Instantly share code, notes, and snippets.

@brenes
Forked from scottwb/application_controller.rb
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save brenes/c23d8cf5f4f2adb19c03 to your computer and use it in GitHub Desktop.

Select an option

Save brenes/c23d8cf5f4f2adb19c03 to your computer and use it in GitHub Desktop.
How to get filters from a Controller
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = :around)
_process_action_callbacks.select{|f| f.kind == kind}.map(&:filter)
end
def self.before_filters
filters(:before)
end
def self.after_filters
filters(:after)
end
def self.around_filters
filters(:around)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment