FInding that before_filters are already installed in Rails 3

I have a DSL for controller configuration. The main functionality depends on before_filters. To prevent the setting of the before_filter parameter more than once, I really need to find out if the before_filter parameter is set in the Rails 3 controller. Since before_filter is different from class variables (inheritance, reloading classes), I cannot just set the class variable to check.

Digging in a new highly abstracted code for AbstractController callbacks doesn't give me any clues if this is possible at all.

Do I really need to call skip_filter for every DSL call in the controller?

+4
source share
1 answer

Below I found a way to do this:

noam$ rails c Loading development environment (Rails 3.0.3) ruby-1.9.2-p136 :001 > ApplicationController._process_action_callbacks.map {|c| c.filter if c.kind == :before}.compact => [:deny_banned_user, :validate_session, :verify_authenticity_token, :require_user_login] ruby-1.9.2-p136 :002 > 
+10
source

All Articles