All threads / Dynamic Nested Forms with Turbo Discussion
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Dynamic Nested Forms with Turbo Discussion

Great demo of an awesome new ability. Thanks!

Thanks, Matt! I'm glad that you enjoyed this video.

This was great. I like the progressive enhancement(?) approach. Thank you.

Thanks, James! Yeah, progressive enhancement is a good description of it. A bit of a refactoring too as we were able to drop the stimulus controller completely. Happy to hear that you enjoyed the video! Thanks for watching.

Love everything about the screencast. The details, right speed and explanation. One thing i wished you would have explained is why the "task_field" action returns a turbo-stream automatically, without having to add code and tell it to respond_to turbo_stream. Seems a bit like magic

Thank you for the kind words and the feedback! To follow up, initially, the "task_field" endpoint does not automatically return a turbo-stream. In the second implementation when we use the RequestJS package to set a { responseKind: "turbo-stream" } on the request that the Stimulus controller makes, that's what triggers the endpoint to respond with a turbo-stream. Then when we remove the Stimulus controller and solely use Turbo, we set a data: { turbo_stream: true } on the link_to helper, that will also cause the endpoint to respond with a turbo-stream. Although the endpoint is empty during these two implementations, by default if a request comes in that wants a turbo-stream the endpoint can either list out how to respond to a turbo-stream request in the action or by convention look for a matching named turbo-stream view i.e. "app/views/projects/task_field.turbo-stream.erb". This is much like the convention of how a given action, let's say an index action of a Post controller, would look for a view at "app/views/posts/index.html.erb" by default unless instructed otherwise.
Hope this helps clarify that for you!

Can I make the suggestion that you start with a <10 second overview or visual of what you'll develop by the end? Although this was a great video, I had to watch for 14 min to see the totality of what you were going to produce. Fortunately I was interested in that investment, but often I'm on a fine line for a given episode's "is this worth 15 min of my time?". When one knows where you're going, it's much easier to follow. "I'm going on vacation to NYC" happens first, then I decide if I'm driving or flying and what museums to go to.

Totally agree with this comment and also feedback for all the publishers (ie Chris could do this also).

Thanks for taking the time to provide this feedback. The remaining videos that I have coming out for this year are already recorded but going forward I will be sure to keep this in mind and try to provide an opening overview in the videos. I appreciate the feedback!

Fantastic! Would love to see more content around complex/dynamic forms & turbo :)

Thanks! And thanks also for letting us know that you would enjoy more around these topics!

Really enjoyed the explanation, nice work.

nice learning - but half an hours is quite a bunch of time - do you plan to offer a written version of the episodes like Ryan Bates had it with his RailsCasts? Then 30 minutes can become 3 minutes for those who have some pre-knowledge. Thanks.

HI Collin, thanks for the help. For folks like Muhammad Härter, maybe some timestamps, like on YouTube, would improve him getting to what he wants.

This is a very helpful video! I'm trying to implement version 3 - full-turbo-get. For some reason, the link_to on the form page to add a second task is not executing a turbo_stream, but rather is executing the html partial. In my case, the link looks like this:
<%= link_to "Add a Student", chamber_music_entry_field_chamber_music_groups_path, data: { turbo_stream: true } %>
The turbo_stream is not executing - rather, it loads the html version as a new page. My project is running rails 7.0.3 and turbo 1.3.2. What could be causing this?

After further testing, I can get methods 1 and 2 to work correctly, but still method three seems to call the html xxx_field partial and not the turbo_stream partial when clicking on the link_to to add a second nested object.. I can't figure out why.
Another question - I need to pass an array into my equivalent of the task partial. How to I do this on method 2 when using the button_tag that calls the stimulus controller?

Join the discussion

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

Join 70,078+ 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.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.