我想使用与//= require <lib>
不同的文件中的/app/assets/javascripts/application.js
。这会导致资产编译错误,但问题是路径不正确。我做了一个简化的项目,显示https://github.com/rusanu/test-ember处可用的问题。
在layout:
<head>
<title>TestEmber</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= yield :head %>
<%= csrf_meta_tags %>
</head>
在view:
<%= content_for :head do %>
<%= javascript_include_tag "dashboard/dashboard", :cache => 'dashboard' %>
<% end %>
//= require handlebars
//= require ember
//= require ember-data
//= require_self
这会导致错误:
Showing /home/rremus/test-ember/app/views/dashboard/show.html.erb where line #2 raised:
No such file or directory - Asset file not found at '/home/rremus/test-ember/public/home/rremus/.rvm/gems/ruby-2.0.0-p0/gems/handlebars-source-1.0.0.rc4/dist/handlebars.js'
Extracted source (around line #2):
1: <%= content_for :head do %>
2: <%= javascript_include_tag "dashboard", :cache => 'dashboard' %>
3: <% end %>
4:
5: <h1>Dashboard#show</h1>
注意资产路径如何由项目公共目录(/home/rremus/test-ember/public
)组成,然后附加正确的资产路径(/home/rremus/.rvm/...
),从而导致路径不正确。
答案 0 :(得分:2)
我的猜测是你必须做一些特殊的体操才能让它在这种情况下使用缓存指令Rails guide for the asset pipeline。
如果您放弃缓存指令并依赖预编译来处理文件组合,那么事情似乎没有错误。