Ruby on rails 不在局部视图中呈现的内容

Ruby on rails 不在局部视图中呈现的内容,ruby-on-rails,actionview,actionviewhelper,Ruby On Rails,Actionview,Actionviewhelper,我有一个使用布局的rails应用程序 简化版本如下所示: <html> <head> <%= render 'layouts/head' # renders the "layouts/_head.html.erb" partial correctly # the most head (css/js) content gets implemented here %> </hea

我有一个使用布局的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”中的内容不呈现任何内容

我如何解决这个问题

content\u for:blah do
放在回音content\u for/yield标签后面时,
partials
似乎无法为content追加内容

如果我尝试
content\u for:scripts\u bottom
它将在页面底部呈现

提前谢谢

轨道3.2.14
ruby 2.0.0p247

代替
提供
,尝试

如果你想使用
内容
,那么你需要在你的头脑中产生它而不是渲染它

所以你的标题看起来像:

或者,您可以删除部分中
内容_,只需将JS单独放置,如下所示:

<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>


这样您就不必更改布局文件。

在您的
布局/head
部分中,使用
yield:scripts\u head
not content\u for

这是我的第一个方法:不起作用。我纠正了在我的问题中,内容似乎附加了多个
content\u:blah do
块。这是我的最终目标。但它什么都没有。不带
收益率:布拉
,也不带
内容:布拉
<% content_for :scripts_head do %>
    <%= javascript_include_tag 'some_script' %>
<% end %>