rails before_action not in extended classes

267 Views Asked by At

In app/controllers/application_controller

class ApplicationController < ActionController::Base
    before_filter :set_locale_or_redirect
    before_action :set_locale

That code is executed in all controllers. However, I don't want set_locale_or_redirect and set_locale to execute in app/controllers/biblio_controller.rb I tried this:

class Dts::BibliosController < ApplicationController
    skip_before_filter :set_locale_or_redirect, raise: false
    skip_before_action :set_locale, raise: false

no success.

1

There are 1 best solutions below

0
hashrocket On

It's definitely possible. To 'skip' an before_action in a controller, you can use:

skip_before_action :action_name

In your case, it would be:

skip_before_action :set_locale_or_redirect
skip_before_action :set_locale

You can read more here