Rails tutorial "Delete 13.3.4 Microposts" fails

Asked 4 months ago, Updated 4 months ago, 8 views

Rails Tutorial Chapter 13, 13.3.4 Delete Microposts does not work.
As a symptom, clicking on the Delete Micropost link takes you to the Home page, and the micropost that you clicked delete remains.

We have checked the debugs to see that @micropost in the correct_user method in micropost_controller.rb is nil, but the debug will return the replacement expression current_user.microposts.find_by (id:params[:id]).If anyone has seen a similar phenomenon, I would appreciate it if you could give me some advice.


2022-09-30 11:44

1 Answers

Sorry for the trouble.I was able to solve myself.
@micropost=current_user.microposts.find_by(id:params[:id]) The space on the left side of ) seems to have been full-width.
Sorry for the rudimentary mistake.

2022-09-30 11:44

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.