Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的主页视图中包含元标记。但我不想application.html.erb直接将它包含在文件的头部部分,因为这会导致它在所有页面上包含元标记,这对我的应用程序来说是多余的。
application.html.erb
你可以把
<% if content_for?(:head) %> <%= yield(:head) %> <% end %>
在布局head部分。application.html.erb
head
然后,在您想要包含这些标签的视图中:
<% content_for :head do %> <!-- your tags --> <% end %>