If you get an error such as NoMethodError undefined method ʻid'for nil: NilClass error even though you haven't made a mistake, what could be the cause? I got an error saying that the method wasn't defined ... why did I get an error like this when I defined it properly ...
This implementation is used when the logged-in user can see his information but does not want to show it to other users.
<% if @user.id == current_user.id %>
You realize that you are wondering why this happened even though the code you implemented was correct!
#### I wasn't logged in!
It is natural because it is a process that does not work unless you are logged in ^ _ ^;
After logging in and checking again, the error was successfully resolved!
![S__56467458.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/587506/5de0eeb3-502a-6ac6-6c0a-66c553e19f79.jpeg)
Recommended Posts