gpt4 book ai didi

ruby-on-rails - Rails : How to include meta tags in views and not in application. html.erb?

转载 作者:行者123 更新时间:2023-12-03 01:24:09 24 4
gpt4 key购买 nike

我想在我的主页 View 中包含元标记。但我不想将其直接包含在 application.html.erb 文件的 head 部分中,因为这将导致它在所有页面上包含元标记,这对我的应用程序来说是多余的。

最佳答案

你可以放

<% if content_for?(:head) %>
<%= yield(:head) %>
<% end %>

位于 application.html.erb 布局的 head 部分。

然后,在您想要包含这些标签的 View 中:

<% content_for :head do %>
<!-- your tags -->
<% end %>

关于ruby-on-rails - Rails : How to include meta tags in views and not in application. html.erb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17319844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com