[Rails] gem devise installation flow

Introduction

This is Qiita's first post. I'm sorry for the poor text, but I hope you can read it. Thank you.

Install ** gem devise ** for user management features

1. Add the following to the last line of the Gemfile

Gemfile


#abridgement
gem 'devise'  #Please add to the last line

2. Run bundle install in the terminal

Terminal


$ bundle install

3. Check if devise is installed with Gemfile.lock

Gemfile.lock


#abridgement
devise

Apply ** devise **

After the installation is complete, create a configuration file using the devise-specific command.

4. Run rails g devise: install in the terminal

Terminal


#Create devise config file
$ rails g devise:install

** Newly created file **

config/initializers/devise.rb

config/locales/devise.en.yml

5. Run rails g devise user in the terminal

Terminal


#Create a model with the devise command
$ rails g devise user

** Newly created file **

app/models/user.rb

db/migrate/20XXXXXXXXXXXX_devise_create_users.rb

test/fixtures/users.yml

test/models/user_test.rb

Also, the description of devise_for: users is automatically added to config / routes.rb.

config/routes.rb


Rails.application.routes.draw do
  devise_for :users
#abridgement

6. Run rails db: migrate in the terminal

Terminal


#Execute the created migration file
$ rails db:migrate

7. Run rails g devise: views in your terminal

Terminal


#Create a view for devise
$ rails g devise:views

** Newly created file **

app/views/devise/shared

app/views/devise/shared/_error_messages.html.erb

app/views/devise/shared/_links.html.erb

app/views/devise/confirmations

app/views/devise/confirmations/new.html.erb

app/views/devise/passwords

app/views/devise/passwords/edit.html.erb

app/views/devise/passwords/new.html.erb

app/views/devise/registrations

app/views/devise/registrations/edit.html.erb

app/views/devise/registrations/new.html.erb

app/views/devise/sessions

app/views/devise/sessions/new.html.erb

app/views/devise/unlocks

app/views/devise/unlocks/new.html.erb

app/views/devise/mailer

app/views/devise/mailer/confirmation_instructions.html.erb

app/views/devise/mailer/email_changed.html.erb

app/views/devise/mailer/password_change.html.erb

app/views/devise/mailer/reset_password_instructions.html.erb

app/views/devise/mailer/unlock_instructions.html.erb

So far, I have explained the flow when installing gem devise. I hope it will be helpful to as many people as possible.

Recommended Posts

[Rails] gem devise installation flow
What is Rails gem devise?
[rails] error during devise installation
[Rails] devise
[Rails] How to use gem "devise"
[Rails] Manage multiple models using devise gem
[Rails] Introducing devise
rails + devise + devise_token_auth
[Rails] devise helper method
[Rails] Customize devise validation
Doorkeeper gem installation procedure
Handle devise with Rails
[Rails] Heroku deployment flow
[Rails] devise introduction method
Rails, RSpec installation procedure
[rails] About devise defaults
[Rails] Introduction of devise Basics
[Rails] How to install devise
rails g model Overall flow
[Japanese localization of gem: devise]
(For beginners) [Rails] Install Devise
Gem often used in Rails
[Rails] Add column to devise
Memorandum [Rails] User authentication Devise
[Rails] How to use devise (Note)
[Rails] Session timeout setting in devise
[rails] Login screen implementation in devise
[Devise] rails memo basic setting initial setting
[Rails] Unexpected validation error in devise
[Rails] [Devise] Edit profile without password
devise gem Awareness Note: Redirect specs
Ruby On Rails devise routing conflict
[Rails] gem ancestry category function implementation
[Rails] Add strong parameters to devise
Create My Page with Rails devise
Troublesome Rails environment construction flow [Windows 10]