Devise is a very powerful gem, it allows you to sign up, sign in and sign out options just after installing. Moreover user can add authentications and restrictions to its applications. Devise also come with its own views, if user wants to use. A user can also customize sign up and sign in forms according to its need and requirement. It should be noted that Devise recommends that you implement your own login if you're new to rails.
At the time of generating devise configs using
rails generate devise:install, devise will list out bunch of instructions on the terminal to follow.
If you already have a
USER model, running this command
rails generate devise USER will append necessary columns to your existing
Use this helper method
before_action :authenticate_user! at the top of your controller to check whether
user is logged-in or not. if not then they will be redirected to sign-in page.