I posted about the introduction of devise before, so this time I will focus on the methods that can be handled by devise.
[Previous post]
I tried to summarize the devise that was difficult at first sight Continued, I tried to summarize the difficult devise at first sight
Determines if the user is signed in and returns a boolean value.
It is often used with an if statement when you want to change what you want to display between users who are signed in and users who are not. For example, "Logout" for users who are signed in, "Sign in" for users who are not signed in, etc.
Transit users who are not logged in to the login page screen. Often described in the controller as before_action. Even if a user who is not logged in directly enters the url, the transition can be made.
You can get the id of the signed-in user with current_user.id
.
It is often used to collate users who are signed in with users who have posted items.
Recommended Posts