1

I have a Document, and Document has many Pages. On the Document show, you can click a button to delete the page. That button looks like:

= link_to 'Delete', [:super_user, page], data: { turbo_confirm: 'Are you sure?', turbo_method: :delete }

This page also has

= turbo_page_requires_reload

Because I need to break out of a modal that's used for editing the Document. That modal is loaded in a Turbo Frame.

When you click the delete button, it destroys the Page and redirects back to the Document show, but the flash message doesn't appear.

If I disable Turbo, the flash works, but the confirm message does not.

If I remove turbo_page_requires_reload, then the modal no longer breaks out of the frame.

It seems like maybe going back to rails_ujs might give me back the ability to disable Turbo and also get a confirm message, but that seems hacky and/or a step backwards.

I've tried changing the status code of the response on the destroy, the only thing that works is changing it to :unprocessable_entity, but that just seems hacky.

How can I get this working as expected?

Petercopter
  • 1,218
  • 11
  • 16

1 Answers1

0

WELL this is awkward. I was barking up the absolute wrong tree(s).

The reason it wasn't working is because I was adding a stylesheet to the head of the document from the page template. I need a specific stylesheet based off the Account the Document is associated with.

So instead of doing content_for(:head) and adding the stylesheet that way, I changed to just drop the stylesheet into the body, and everything is good.

Phew, that was unexpected!

Petercopter
  • 1,218
  • 11
  • 16