・ Ruby 2.5.7 ・ Rails 5.2.4.3
CRUD processing is done! However, at this rate, all posts can be edited or deleted. I want to make edit and delete permissions only for posters.
unless means if it wasn't. In the following, If the ID of the received user does not match the ID of the logged-in user (current_user), it means that the process will not be executed and the redirect will be returned.
before_action is the one that is executed before all the actions of the controller are executed. This time I want to do it only for editing and deleting, so I only edit, update and destroy.
Recommended Posts