How do I make a before_action to run on all controllers and actions except one?

What you have to do is to set autheticate_user! on all controllers like that :

class ApplicationController < ActionController::Base
  before_action :authenticate_user!
  ...
end

And then on your HomeController you do that :

class HomeController < ApplicationController
  skip_before_action :authenticate_user!, only: [:index]
  ...
end

Hope this will help you !

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)