From the course: Hands-On Introduction: Ruby on Rails

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Using Turbo Frames to display the form

Using Turbo Frames to display the form - Ruby on Rails Tutorial

From the course: Hands-On Introduction: Ruby on Rails

Using Turbo Frames to display the form

- [Instructor] As I told you in the previous video, we'll use Turbo Frames to display the New Post form. Open the Index template and in the New Post link add a data attribute with the turbo_frame property, that will indicate where the destination will be loaded in the element with the ID of a new post. Here, we'll create that element as a turbo_frame_tag with the same ID. Let's see what code this generates. Start the server. Reload the list and open the source code. The link has this data property that points to the element with a new post ID. And that element is down here. This is where the content will be loaded. Go back to the editor and open the new template. Now from this template, with the limit what we want to load dynamically? It'll be only the form, so wrap the form render with a turbo_frame tag. Set in as ID the post object. This ID must match the one we've created in the index template. Let's see the effect. Reload the list and click on New Post. As you can see, the New…

Contents