Answer the question
In order to leave comments, you need to log in
Why doesn't the author check the existence of an object in the database before deleting it?
I've seen code like this many times:
def destroy
user = User.find params[:id]
user.destroy!
render nothing: true, status: 204
end
Answer the question
In order to leave comments, you need to log in
because the code will fall user = User.find params[:id] - on this line it will not reach the end yet. this is a kind of test.
1. Because, as Semyon Semyonov said , these are just examples.
2. An exception will occur ActiveRecord::RecordNotFound
3. The question is not clear, what does it mean to configure server errors?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question