Ask an AI coding assistant to fix a broken delete button in a Rails 8 app and there is a good chance you get something like this back:
skip_forgery_protection only : :destroy
def destroy @post . destroy render json : { ok : true } end
Enter fullscreen mode
Exit fullscreen mode
Plus a new /api route and a Stimulus controller that calls fetch() with method: "DELETE" .
It works. It is also the wrong fix. You just turned off CSRF protection on a destructive action and bolted a second architecture onto an app that was built to render HTML.
What actually broke
In older Rails apps, link_to "Delete", post, method: :delete relied on rails-ujs to turn a link into a DELETE request. Rails 7+ apps run on Turbo instead, and that old method: :delete on a link does nothing useful anymore. The click becomes a GET to the show page.
The assistant sees "delete doesn't work," notices Turbo is involved, and reaches for the pattern it has seen a million times in React tutorials: a JSON endpoint and a fetch call.…