I have started to use Devise gem and now trying to implement the code, so my web app will require to login for each and every page on my app. I have added the following code to routes.rb according to this instruction:
authenticated :user do
root to: 'home#index', as: :authenticated_root
end
root to: redirect('/users/sign_in')
but it doesn't work. When I go to any page - it just open that page, and doesn't forward me to the sign_in page. Could anyone please clarify what I missed? Any help would be appreciated.
Add this to your app controller
class ApplicationController < ActionController::Base
...
before_action :authenticate_user!
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With