Create a user model using devise
I installed devise by creating a personal application.
First, enter the following in the Gemfile.
By the way, devise is said to mean ** “invent, devise, devise, invent” ** in Japanese.
Then at the terminal
『rails g devise:install』
『rails g devise user』
Are executed in order.
Then edit the migration file as follows.
- Caution: You can omit #.
** ① null: false is used to prevent saving in an empty state. ** **
** ② unique: true is used to prohibit duplicate names in the table. ** **
Next, edit app / models / user.rb as follows.
** Validates means to verify in Japanese, presence means existence, and uniqueness means uniqueness. ** **
By translating the code written in English into Japanese, I felt that the meaning could be understood well.
** Also, migration seems to mean move, migration. In other words, the migration file may be an image like a blueprint for moving to a database table. ** **