Describe at the bottom of Gemfile
gem 'devise'
% bundle install
Reboot the server
% rails s
Install devise config file in rails application
% rails g devise:install
After execution
You can create the following two files.
config/initializers/devise.rb config/locales/devise.en.yml
Execute the command to create a User model
% rails g devise user
After execution
A message is displayed as shown below.
#Omission
create db/migrate/20200523092621_devise_create_users.rb
create app/models/user.rb
Write the required column (name column this time) and execute migration
-Created with NOT NULL constraint that does not allow empty values
db/migrate/20XXXXXXXXXXXX_devise_create_users.rb
class DeviseCreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
## Database authenticatable
t.string :name, null: false
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
#~abridgement~
end
Perform migration
% rails db:migrate
Restart local server after changing table / column information
Recommended Posts