1

我想使用//= require <lib>/app/assets/javascripts/application.js. 这会导致资产编译错误,但问题是路径不正确。我做了一个简化的项目,显示https://github.com/rusanu/test-ember上的问题。

布局中:

<head>
  <title>TestEmber</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= yield :head %>
  <%= csrf_meta_tags %>
</head>

视图中:

<%= content_for :head do %>
<%= javascript_include_tag "dashboard/dashboard", :cache => 'dashboard' %>
<% end %>

在我的仪表板/dashboard.js中:

//= 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/...附加正确的资产路径 ( ),从而导致路径不正确。

4

1 回答 1

2

我的猜测是,在这种情况下,根据资产管道的 Rails 指南,您必须做一些特殊的操作才能使其与缓存指令一起使用。

如果您放弃缓存指令并依靠预编译来处理文件组合,那么事情似乎可以正常工作。

于 2013-05-26T02:14:01.517 回答