Get the latest tech news

Auto-saving Rails forms with Turbo Streams


Here’s how to implement autosaving for inline input fields the Hotwire way.

We just wrap it with data-controller set to our Stimulus controller name and provide data attributes on the form and the field in question: I used the blur event to autosave on lost focus but you could also use change to immediately save any progress (at the expense of many HTTP calls). I spent a considerable amount of time chasing an issue with wrong field focus.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of saving rails forms

saving rails forms

Photo of turbo streams

turbo streams