Steps to reproduce
View:
<%= link_to "Destroy", @question, data: { 'turbo-method': :delete, 'turbo-confirm': 'Are you sure?' } %>
Controller:
def destroy
@question = current_user.questions.find(params[:id])
@question.destroy
redirect_to questions_url, notice: "Question was successfully destroyed."
end
Expected behavior
The question is deleted and the user redirected to the questions index.
Actual behavior
The question is deleted and the user is redirected to the question (instead of question index as defined in the controller!) where he gets an obvious error:
ActiveRecord::RecordNotFound in QuestionsController#show
Couldn't find Question with 'id'=6
inside def show
System configuration
Rails version: 7.0.1
Ruby version: 3.1
Steps to reproduce
View:
Controller:
Expected behavior
The question is deleted and the user redirected to the questions index.
Actual behavior
The question is deleted and the user is redirected to the question (instead of question index as defined in the controller!) where he gets an obvious error:
System configuration
Rails version: 7.0.1
Ruby version: 3.1