How do I make a before_action to run on all controllers and actions except one?
<p>I have a rails 4.2.x app, with devise for authentication - I have several controllers. </p>

<p>I want the devise authenticate_user! method to be run on all controllers and actions except on the home controller index action. (Of course, authenticate_user! itself takes care that devise actions like login go through)</p>

<p>I can ensure that every controller action runs the before_action in application_controller.rb:</p>

<pre><code>class ApplicationController &lt; ActionController::Base
  before_action :authenticate_user!
  ...
end
</code></pre>

<p>I can also restrict a specific set of actions on <em>all</em> controllers:</p>

<pre><code>class ApplicationController &lt; ActionController::Base
  before_action :authenticate_user!, except: [:index]
  ...
end
</code></pre>

<p>But I don't see how to make just home/index to be an exception. </p>

<p>I could, of course, manually add <code>before_action :authenticate_user!</code> to every controller, and add an exception to the home controller for the index action. But this is not very dry, and if I add new controllers, I need to remember to add this before_action to each of them.</p>