I simply can do a
if not user_signed_in?
redirect_to new_user_session_path
for each action need authentication. I imagine there should be more elegant way to do so.
Thanks
I simply can do a
if not user_signed_in?
redirect_to new_user_session_path
for each action need authentication. I imagine there should be more elegant way to do so.
Thanks
Add before_filter :authenticate_user!
in the controllers that should have user authentication.
Reference: https://github.com/plataformatec/devise#controller-filters-and-helpers
If not all actions in the controller require user authentication, implement a custom before filter as explained in https://stackoverflow.com/a/6034498/429758
If the whole application needs user authentication, then the above line belongs in app/controllers/application_controller.rb
file.