【发布时间】:2011-09-15 16:14:03
【问题描述】:
我有一个 rails 3.1 应用程序,它按照标准做法在“/app/assets/stylesheets/application.css”中使用带有 css 的默认布局。这对我的应用程序主要部分的资产流水线非常有用。
但是,当我生成使用 /app/views/layouts/showreports.html.erb 布局的报告时,我使用了不同的“报告”布局,如下所示:
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag "showreports" %>
<%= javascript_include_tag "showreports" %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="mainarea" class="container">
<div class="span-24 last">
<%= yield %>
</div>
</div>
</body>
我正在使用 rake assets:clean; rake assets:precompile 预编译我的资产并检查清单文件 (/public/assets/manifest.yml) 中的内容是否正常,但我没有看到任何对 showreports.css 或 showreports 的引用.js。
当我在开发模式下测试我的程序时,不出所料,它找不到那些文件。
我猜这是 rails 3.1 的基本 sprockets 问题,但我认为 sprockets 足够聪明,可以解析资产的所有布局文件(超出默认的 application.html.erb 文件)。
只是想知道这可能是一个错误还是我对它应该如何工作的误解。
干杯,
格雷格
更新
经过更多修改,我正在回答我自己的问题,因为这对我来说最有意义......
This answer really gave the right clue
我做错的是使用名为“showreports.css”和“showreports.js”的文件作为清单文件。
我的解决方法是创建 /app/assets/stylesheets/showreports 和 /app/assets/javascripts/showreports,然后在它们各自的目录中将我的 showreports.(css|js) 重命名为 application.(css|js)。
这样做后,rake assets:precompile 很好地找到了它们并将它们正确添加到清单文件中。
【问题讨论】:
标签: ruby-on-rails-3.1 asset-pipeline sprockets