A gem for user management in Rails apps, The basic procedure for introducing "devise" Introduced as a memorandum.
Described in the bottom line.
Run ** bundle instrall **.
rails g devise:install
Unlike the normal model creation command, it is a devise-specific command, Create a User model.
rails g devise user
After execution, "devise_for: users" is added to the routing, It seems that login and new registration will generate the required routing.
◉ Continue to execute.
Create a button for "new registration" and "login" in the header etc. Due to the ** user_signed_in? Method **, the display will be different when you are not logged in than when you are logged in.
.header .header__user-btn - if user_signed_in? = link_to "New post", new_post_path, class: "btn" = link_to "Log out", destroy_user_session_path, method: :delete, class: "btn" - else = link_to "Login", new_user_session_path, class: "btn" = link_to "sign up", new_user_registration_path, class: "btn"
Display the screen for actually entering registration and login information.
rails g devise:views
Up to this point, registration → login → logout has been implemented.
That is all. Thank you for visiting.