[RUBY] A description that only the poster can access

Development environment

Ruby 2.6.5 Rails 6.0.3.3

problem

I want to implement it so that only the poster can delete the review, but I get a NoMethodError

Cause

Initially, the conditional expression was described as follows.

<% if current_user.id == @review.user_id %>

This is a description that if the user who is currently logged in and the poster are the same, the conditional expression will be True and the process will be executed. However, when I read it with this description, an error occurred.

When I checked it, the description was as follows.

<% if user_signed_in? && current_user.id == @review.user_id %>

By confirming the presence or absence of login with this description, it is now possible to process normally. This is a rudimentary part, but I noticed it again, so I posted it as a memorandum.

Recommended Posts

A description that only the poster can access
I tried a puzzle that can only be solved by the bottom 10% of bad engineers
Mechanism for converting to a language that the browser can recognize
Set the access load that can be changed graphically with JMeter (Part 2)
Set the access load that can be changed graphically with JMeter (Part 1)
The strongest Omikuji app that only I, an EKS Lover, can think of
A shell script that builds the OpenJDK11 source
The story that docker had a hard time
A story about making a Builder that inherits the Builder
A description of Interface that is often mistaken
[Ruby On Rails] Description that allows only specific users to transition to the edit page
3. Create a database to access from the web module
Write a class that can be ordered in Java
About the matter that hidden_field can be used insanely
A command that definitely cleans the local docker environment
Code that only displays the built-in camera in Processing
A scraping of past weather that can be seen on the Japan Meteorological Agency website
[Ruby] Extract only the elements that match the conditions and create a new array. filter and select
[Java] I tried to make a rock-paper-scissors game that beginners can run on the console.