在我的application.html.haml
中=stylesheet_link_tag "application", :media => "all"
=javascript_include_tag "jquery-1.11.0.min"
=javascript_include_tag "jquery-ui-1.10.4.min"
=javascript_include_tag "angular.min"
=javascript_include_tag "angular-route.min"
=javascript_include_tag "angular-resource.min"
=javascript_include_tag "angular-ui-router.min"
这些js文件目前在我的app / assets / javascripts文件夹中
当我将它部署到heroku时,我继续
3848+00:00 app[web.1]: 9: =stylesheet_link_tag "application", :media => "all"
2014-05-01T21:25:16.063849+00:00 app[web.1]: 10: =javascript_include_tag "jquery-1.11.0.min.js"
2014-05-01T21:25:16.063846+00:00 app[web.1]: ActionView::Template::Error (html5shiv.js isn't precompiled):
2014-05-01T21:25:15.995499+00:00 app[web.1]: Started GET "/" for 128.31.34.63 at 2014-05-01 21:25:15 +0000
2014-05-01T21:25:16.051098+00:00 app[web.1]: Rendered home/index.html.haml within layouts/application (10.3ms)
2014-05-01T21:25:16.063843+00:00 app[web.1]:
2014-05-01T21:25:16.063851+00:00 app[web.1]: 11: =javascript_include_tag "jquery-ui-1.10.4.min.js"
2014-05-01T21:25:16.063853+00:00 app[web.1]: 12: =javascript_include_tag "html5shiv.js"
2014-05-01T21:25:16.063854+00:00 app[web.1]: 13: =javascript_include_tag "angular.min.js"
2014-05-01T21:25:16.063858+00:00 app[web.1]: 15: =javascript_include_tag "angular-resource.min.js"
2014-05-01T21:25:16.063856+00:00 app[web.1]: 14: =javascript_include_tag "angular-route.min.js"
2014-05-01T21:25:16.063860+00:00 app[web.1]: app/views/layouts/application.html.haml:12:in `_app_views_layouts_application_html_haml___1963393475950734090_70074639367120'
我一直在获取资产编译错误。我应该在我的application.js中要求它们吗?在我的application.js我有这些
//= require jquery_ujs
//= require bootstrap
//= require_tree .
我将此添加到我的config / environments / production.rb
config.assets.precompile += %w(email.css event_creation_dynamic_form.js jquery-1.11.0.min.js jquery-ui-1.10.4.min.js angular.min.js angular-route.min.js)
对我来说并没有真正起作用。我不太熟悉rails中的资产管道以及heroku资产管道的工作原理。我也尝试过运行
heroku run rake assets:precompile
我的javascript文件也都是缩小版。我希望这是正确的生产版本。 我是否正确使用了js include标签?
答案 0 :(得分:2)
看起来Heroku已经方便地告诉你问题是什么:
ActionView::Template::Error (html5shiv.js isn't precompiled)
因此您需要将该文件添加到预编译数组中,如下所示:
config.assets.precompile += %w(html5shiv.js, any-other-files-here)
话虽如此,为了回答你的问题,不,你并没有真正正确使用js include标签。
您应该在application.js中包含那些js文件。这样,文件将与application.js一起预编译,您不必将它们添加到预编译路径中。例如,在application.js中:
//= require path/to/jquery-1.11.0.min.js
//= require path/to/jquery-ui-1.10.4.min.js
//= require path/to/angular.min.js
//= require path/to/angular-route.min.js
//= require path/to/angular-resource.min.js
//= require path/to/angular-ui-router.min.js