All threads / How to handle flash messages with TurboJS?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to handle flash messages with TurboJS?

Johan André asked in Gems / Libraries

When using turbo-frame to switch from showing a partial of model to showing the form of model, how do I handle flash messages?
The failed state - for failed validation - is pretty straight forward, since I re-render the form and outlining the validation errors in the form. But when a form is successfully submitted I would like to show a message (preferably like a toast) saying the data is saved.

Any ideas how to do that in a clean way?

You can use a turbo stream to insert the flash message into a div for them. 👍

I'm actually going to do a screencast on this shortly.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 47,776+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.