[英]Javascript_Include_Tag Not Working. How do I fix it?
In my Rails 3 view I have the following code:在我的 Rails 3 视图中,我有以下代码:
<% content_for :head do %>
<%= javascript_include_tag "home" %>
<%= stylesheet_link_tag "home-style" %>
<% end %>
For some reason neither include shows up.由于某种原因,既不包括出现。 If I manually type in
<script type="text/javascript" src="/javascripts/home.js">
everything works fine, but I can't seem to get anything to show up using javascript_include_tag
or stylesheet_link_tag
.如果我手动输入
<script type="text/javascript" src="/javascripts/home.js">
一切正常,但我似乎无法使用javascript_include_tag
或stylesheet_link_tag
显示任何内容。 Does anyone know what I could be doing wrong?有谁知道我可能做错了什么? Thanks in advance!
提前致谢!
The generated HTML is:生成的 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>
Did you add <%= yield:head %>
in your application.html.erb file:您是否在 application.html.erb 文件中添加了
<%= yield:head %>
:
<html>
<head>
<%= yield :head %>
</head>
<body>
<%= yield %>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.