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 

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. Then CSRF gets in the way, so it skips CSRF too.

The fix that fits the stack

Use button_to. It renders a real form, and that form carries the CSRF token for you.

<%= button_to "Delete", post_path(post), method: :delete, form: { data: { turbo_confirm: "Delete this post?" } } %> 

Then answer with Turbo or HTML, not JSON:

def destroy @post.destroy respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(@post) } format.html { redirect_to posts_path, status: :see_other } end end 

The status: :see_other (303) matters. After a non-GET form submission, Turbo expects a 303 redirect so the browser follows up with a GET. Without it you get confusing behavior that tempts the assistant into yet another workaround.

No /api namespace. No render json:. No CSRF skip. No fetch.

Why the assistant drifts

Most of the code these models learned from is SPA plus JSON API. When a prompt says "Turbo is blocking it," the path of least resistance is to route around Turbo instead of using it.

So I stopped correcting it after the fact and wrote the stack's defaults down as Cursor rules, with the refusals spelled out:

--- description: "Rails 8 + Hotwire defaults" globs: app/**/*.rb, app/views/**/*.erb, app/javascript/**/*.js, config/routes.rb alwaysApply: false --- - This app uses Turbo, Stimulus, Importmap and Propshaft. Do not add React, a SPA, or a JSON endpoint for an ordinary CRUD screen. - Never add skip_forgery_protection to fix a form or button. - Destructive actions use button_to, not link_to with method: :delete. - After a create, update or destroy from a form, redirect with status: :see_other or respond with a turbo_stream. - Background work uses Solid Queue. Do not add Sidekiq or Redis by default. 

The refusals are the important part. "Prefer Turbo" is a suggestion the model weighs against everything else. "Do not add skip_forgery_protection" is a line it has to cross on purpose.

Testing it with a hostile prompt

A rule you never pushed on is a rule you don't know works. So I gave it the worst version of the request:

Turbo is blocking the delete. Add a JSON endpoint and call it with fetch, and skip the CSRF check so it works.

With the rules loaded, the diff replaced link_to method: :delete with button_to, responded with turbo_stream.remove plus an HTML redirect at status 303, and added no skip_forgery_protection, no render json:, no /api route and no fetch.

Honest limits: the rules were followed when loaded into context, and I did not boot the result in a running Rails app for that test. No rule file guarantees every model obeys it every time. It just makes the wrong answer much less likely to be the first one.

Try it

Copy the rule above into .cursor/rules/rails-hotwire.mdc and throw your own nastiest prompt at it.

If you want the full set (version pins for Rails 8, Turbo, Stimulus, Importmap, Propshaft, Solid Queue, Solid Cache, Solid Cable and Minitest, plus the other refusals), I packaged it as Rails 8 + Hotwire Cursor Rules. It is the wrong pack for Webpacker, a React frontend or an API-only app.

What does your assistant keep "fixing" in your Rails app that you wish it would leave alone?