Adding Users

Learn how to add new users to the existing app

Let’s start by creating a model and database table to hold our administrators’ usernames and passwords. Rather than store passwords in plain text, we’ll store a digest hash value of the password. By doing so, we ensure that even if our database is compromised, the hash won’t reveal the original password. We will use the forms:

depot> bin/rails generate scaffold User name:string password:digest

We declare the password as a digest type, which is another one of the nice extra touches that Rails provide. Now run the migration as usual:

depot> bin/rails db:migrate

A live terminal

You can run the above commands by using the following terminal.

Get hands-on with 1200+ tech skills courses.