Search code examples
ruby-on-railsruby-on-rails-4cancan

Redirect all pages to Sign in, in RAILS 4


I've been looking for a way to redirect all requests of my app to the sign_in page if the user is not signed in, but I haven't found a way to do it (I could do it verifying a system variable and then redirect_to, but it does sound like the bad way)

I'm using ldap_authenticatable (devise) to authenticate, and then use Cancancan (for Access Control List), is there a way to use those tools (Cancancan) to do this ? , or how should I do it?

Thanks for your time


Solution

  • You can just add before_filter :authenticate_user! to your base ApplicationController. Devise Docs