Before_filter: is it possible to specify a controller for an action?

I have the following line in my application_controller:

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

But in the case of: show, I need to put {: controller => 'users' ,: action => 'show'} in the exception. Can this be done?

+7
ruby-on-rails
source share
1 answer

Options:

  • Use skip_before_filter in UserController

    skip_before_filter :login_required, :only => :show

  • Applying before_filter individually for each controller if your exceptional cases grow.

+11
source share

All Articles