http://guides.rubyonrails.org/layouts_and_rendering.html
- `<%= javascript_include_tag "main" %>``
- `<%= stylesheet_link_tag "main" %>``
<%= image_tag "header.png", alt: "My Image", class: "my-class" %>
- `<%= video_tag "video.mp4" %>``
- `<%= audio_tag "song.mp3" %>``
Multiple yields with content_for
:
<html>
<head>
<%= yield :head %>
</head>
<body>
<%= yield %>
</body>
</html>
The main body of the view will always render into the unnamed yield. To render content into a named yield, you use the content_for method.
<% content_for :head do %>
<title>A simple page</title>
<% end %>
<p>Hello, Rails!</p>
To render a partial into a specific place in the layout:
<%= render "shared/menu" %>
To render a partial into a specific layout:
<%= render partial: "link_area", layout: "graybar" %>
Passing variables to a partial:
<%= render partial: "form", locals: { show_title: false } %>
The partial (_product.html.erb) will be inserted once for each item in the collection:
<%= render partial: "product", collection: @products %>