before_filter :except => [:controller => :main_menu] ??? do we have such thing

Hi all

I have added a before_filter method in my application. Mainly most of the controllers use that method except one controller. The whole controller does not use this method, so I want to exclude it from the list

I tried before_filter :authenticate, :except => [:methods_here ]

but how can we make an except for a controller


You can add guards in the filter, based on the controller and/or action names. Example:

   #in application.rb      before_filter :login_required, :except => [:welcome,:login]

     def login_required          return if self.controller_name == 'test' <<----- GUARD

         unless current_user              redirect_to login_invite_url          end      end PS: Ref link:


Thanks for the fast answer in fact I find a way there is a method called skip_before_filter which you add it into the controller and it will do the job


Great !

Yeah I'm using the skip_before_filter method too, but still, it seems it would be better if you could specify a controller/action like your original posts suggests

before_filter :custom_filter, :except => {:controler=>:action}

that way you can include the filter on everything by applying it to the ApplicationController, and only remove it from the few controllers/actions that don't need it.

before_filter :filter_method, :only => :action


before_filter :filter_method, :except => :action

See the 'Filter conditions' section of

Hope that helps, Jim