12 points by strzibny 12 hours ago | 3 comments
Kerrick 8 hours ago
Forgive me if I'm wrong, but I think you can avoid the extra `<div>` element and `formTarget`. You can use `this.element` to do so [0].

    import { Controller } from "@hotwired/stimulus";
    
    export default class extends Controller {
      submit(event) {
        event.preventDefault();
        this.element.requestSubmit();
      }
    }
and

    <%= form_with(model: post, url: post_path(post), data: { "controller": "autosave" }) do |form| %>
      <%= form.label :title %>
      <%= form.text_field :title, class: "input", data: { action: "blur->autosave#submit" } %>
        
      <turbo-frame id="title-status">
      </turbo-frame>
    <% end %>
[0]: https://stimulus.hotwired.dev/reference/controllers#properti...
xutopia 8 hours ago
Honestly Turbo Streams and Hotwire have been a game changer for me. I can do so much with so little code. I can’t believe so many people are stuck in react hell.
candyapplecorn 8 hours ago
I was learning Ruby on Rails all over again during my job search last year and I was working my way through a turbo + turbo streams tutorial. It was very interesting. I almost completed the tutorial, but then I got a job involving legacy C# codebases and React among other things. I ought to go back and finish that tutorial so I can start spitting out personal sites in RoR. I went to a coding bootcamp once that taught RoR in API mode and had us build React frontends. Of course we made .irb templates first but that was just an exercise or two. Now that I’ve got years of experience though I think I’d much rather just go all-in with the RoR framework and use Turbo Steams and Hotwire. There might be things that turbo streams and hotwire can’t do, but I’ve seen some examples of people doing very SPA-ish things with it; in fact to my knowledge currently, most any kind of website can be done with turbo streams and hotwire, and a lot of the types of websites made with SPA’s can be done with turbo streams and Hotwire too. I think it’d meet every need I’d ever have, unless I wanted to literally make something super complicated like an interactive game console in a web browser. Even then I can see turbo + turbo streams getting away with that. IDK. Seems pretty great to me
8 hours ago