Skip to content

Instantly share code, notes, and snippets.

View victor95pc's full-sized avatar
🇵🇹

Victor Castro victor95pc

🇵🇹
View GitHub Profile
@scottwb
scottwb / application_controller.rb
Created February 17, 2012 06:12
Get a list of all the filters on a given Rails 3 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 = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end