Search code examples
ruby-on-railsbefore-filter

before_filter: is it possible to specify controller for action?


I'm having the following string in my application_controller:

  before_filter :login_required, :only => [ :edit, :update, :show, :index ] 

But in case with :show, I need to put {:controller => 'users', :action => 'show'} in exception. Is it possible to do that?


Solution

  • Options:

    • Use a skip_before_filter in the UsersController

      skip_before_filter :login_required, :only => :show

    • Applying the before_filter individually to each controller, if your exceptional cases grow.