Iteration I1: Adding Users
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, so it canât be used to log in as this user using 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 provides. Now run the migration as usual:
â | âdepot>ââ ââbin/railsââ ââdb:migrate ... |
Get Agile Web Development with Rails 5, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.