开发者

Javascript_Include_Tag Not Working. How do I fix it?

In my Rails 3 view I have the following code:

<% 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 <scri开发者_运维问答pt 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. Does anyone know what I could be doing wrong? Thanks in advance!

The generated HTML is:

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

<html>
  <head>
    <%= yield :head %>
  </head>
  <body>
    <%= yield %>
  </body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜