Alias for #append_before_filter
To specify that the filter should be applied to or excluded from given controller actions, use the :only and :except parameters. To pass in multiple controller actions use an array:
before_filter :authorize, :except => [:index, :show] before_filter :authorize, :only => :delete
I am not sure I get your “method 1” alec-c4; won’t that define the method each time the before_filter is called? Why not just define the method in the controller?
You can pass parameters or call protected methods with instance_eval:
before_filter :only => :show do |controller| controller.instance_eval do redirect_to edit_object_path(params[:id]) end end
If you need to track and log which before filters are called for the purpose of debugging your app/before_filters. Then here’s a suggestion, how this could be accomplished: