How to apply before_filter to every action of every controller in Rails 3.2.11?

sergserg picture sergserg · Feb 7, 2013 · Viewed 13k times · Source

I'd like to verify if the user is logged in on every single request to the server.

Something like:

:before_filter verify_logged_in

Where should I put that before_filter so it applies to all controller actions and all requests?

Answer

David Hahn picture David Hahn · Feb 7, 2013

To ensure that filters apply to all actions, place it in the application_controller.rb.