How to Set Up Basic Authentication in Rails

Creating Migrations and Models

The first step in authenticating is to make sure that you actually have a model for your users established so that user information is stored upon creating an account. To do this you first need to have a rails backend created:

Controllers and Routes

Once the migrations and models are complete, it’s time to go to the routes.rb file and add the appropriate routes. Since we are going to be saving user information with the use of sessions, we need to create a SessionsController. For signing up and creating a new user, we need a route that points to our Users Controller.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store