我有一个使用布局的 Rails 应用程序
简化版如下所示:
<html>
<head>
<%= render 'layouts/head' # renders the "layouts/_head.html.erb" partial correctly
# the most head (css/js) content gets implemented here %>
</head>
<body>
<%= yield # renders the current action %>
<!-- implement alls scripts which should be exectued on the bottom of the page -->
<%= content_for :scripts_bottom %>
</body>
</html>
在我的“layouts/_head.html.erb”中,我使用
<%= content_for :scripts_head %>
<!-- it seems `content_for` instead of `yield` appends content -->
在我partials
的地方,我放置了以下片段来附加它们:scripts_head。(我的一些部分应该放 javaScripts
<% content_for :scripts_head do %>
<%= javascript_include_tag 'some_script' %>
<% end %>
`layouts/head' 中的 content_for 不呈现任何内容
我该如何解决?
当将其放置在回显的 content_for / yield 标签后面时,它看起来partials
无法附加他们的 content_for 内容。content_for :blah do
如果我尝试尝试content_for :scripts_bottom
,它将在页面底部呈现。
提前致谢
导轨 3.2.14 红宝石 2.0.0p247