Ask Your Question
4

What is the process for adding a Turbo Frame to `application.html.erb` in Turbo-Rails?

asked 2022-10-04 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-01-17 10:00:00 +0000

david gravatar image

To add a Turbo Frame to application.html.erb in Turbo-Rails, follow these steps:

  1. Identify the section of the application.html.erb layout where you want to add the Turbo Frame.

  2. Add the turbo_frame_tag helper method with the desired ID and src URL inside that section.

Example:

<body>
  <nav>...</nav>
  <%= turbo_frame_tag "my_frame", src: some_path %>
  <main>...</main>
  <footer>...</footer>
</body>

In this example, the turbo_frame_tag is added inside the body section with an ID of "my_frame" and a src of some_path.

  1. Save the changes to application.html.erb.

Now the Turbo Frame is added to the layout and ready to use in any views that render within it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-04 11:00:00 +0000

Seen: 9 times

Last updated: Jan 17 '23