在我的Rails 3视图中,我有以下代码:
<% content_for :head do %>
<%= javascript_include_tag "home" %>
<%= stylesheet_link_tag "home-style" %>
<% end %>
由于某些原因,既不包括出现。如果我手动输入一切正常,但我似乎无法使用javascript_include_tag或stylesheet_link_tag显示任何内容。有谁知道我做错了什么?提前谢谢!
生成的HTML是:
<!DOCTYPE html>
<html>
<head>
<script src="/javascripts/jquery.js?1310704251" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1310704251" type="text/javascript"></script>
<script src="/javascripts/application.js?1310723736" type="text/javascript"></script>
<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="uCZdtztzlgDDUqTG+FvjhuQL6hFFAnwXTcAnvMGX4Ug="/>
</head>
<body>
</body>
</html>
答案 0 :(得分:8)
您是否在application.html.erb文件中添加了<%= yield :head %>
:
<html>
<head>
<%= yield :head %>
</head>
<body>
<%= yield %>
</body>
</html>