我正在尝试在我的应用程序中设置一个模态jQuery脚本,它适用于本地/开发,但当我将它推送到heroku时,脚本不起作用。
我查看了html源代码,我认为它与资产管道有关。我在slug编译期间编译资源(heroku push)。
以下是本地资源的来源:
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/custom.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/pages.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/photos.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.masonry.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.simplemodal-1.4.3.js?body=1" type="text/javascript"></script>
<script src="/assets/pages.js?body=1" type="text/javascript"></script>
<script src="/assets/photos.js?body=1" type="text/javascript"></script>
<script src="/assets/photos.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<link href="/assets/custom.css?body=1" media="screen" rel="stylesheet" type="text/css" />
然而,在制作(heroku)时,我只是得到:
<link href="/assets/application-0183e1470ce8e2ba6f27e018f2b8aabf.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application-20571ddeb4d7b86e69d16370f197cec1.js" type="text/javascript"></script>
<link href="/assets/custom-3ab2912a0b988babf6979cc153672fe0.css" media="screen" rel="stylesheet" type="text/css" />
这就是我的application.html.erb的样子:
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= stylesheet_link_tag 'custom', :media => 'screen' %>
<%= csrf_meta_tags %>
和我的application.js
//= require jquery
//= require jquery_ujs
//= require_tree .
任何线索如何在生产中加载我的所有javascript / jQuery文件? 如果你们需要任何其他文件,请告诉我。
感谢。
答案 0 :(得分:1)
您是否尝试过本地编译资产? Slug编译对我来说似乎不稳定(它讨厌bootstrap)。
RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "vendor compiled assets"
https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar