我有rails项目和视图new.html.slim
:
我试过以下:
= javascript('app/vendor/assets/javascripts/handelbars.runtime.js')
= javascript('../../../vendor/assets/javascripts/handelbars.runtime.js')
= javascript('./vendor/assets/javascripts/handelbars.runtime.js')
但404 Not Found
handelbars.runtime.js
所有vendor/assets/javascripts/
图书馆的正确途径是什么?
我不会在application.js
中包含handelbars.runtime.js
如果我在浏览器中查看路径:
http://localhost:3000/javascripts/vendor/assets/javascripts/handelbars.runtime.js
但我也得到了:
Routing Error
No route matches [GET] "/javascripts/vendor/assets/javascripts/handelbars.runtime.js"
也只是为了测试:
Routing Error
No route matches [GET] "/vendor/assets/javascripts/handelbars.runtime.js"
答案 0 :(得分:2)
= javascript_include_tag "handlebars.runtime"
如果您将其放在视图的末尾,那么它将包含在文档中。如果您希望将其包含在头部或底部,请使用yield <symbol>
功能来实现此目的。例如,如果我的布局中有<%= yield :head %>
,我可以将上面的include标记调用放入content_for:
= content_for :head do
= javascript_include_tag "handlebars.runtime"