【发布时间】:2011-10-21 06:08:34
【问题描述】:
我正在部署到 heroku,但我看到 css 文件没有被提供(它们也无法在 heroku 上找到)。
我读到我需要做 rake assets:首先在本地预编译,但当我这样做时,我得到:
C:\project>bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
undefined: Unexpected token: operator (<)
(in C:/project/app/assets/javascripts/application.js)
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
我在 application.js 中什么都没有,所以我不明白错误在哪里..
application.js 是
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
谢谢
更新
如果删除 .js.erb 文件,我会收到以下错误
C:\project>bundle exec rake assets:precompile RAILS_ENV=production --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
706: unexpected token at 'C:\Users\me\AppData\Local\Temp\execjs20111021-6448-ei2nm3.js(2, 3) Microsoft JScript runtime error: Out of memory
'
(in C:/project/app/assets/javascripts/application.js)
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
erb css和js文件无法编译还是有问题...
这似乎没有结束.. 谢谢
【问题讨论】:
-
您的
javascripts目录中是否有任何javascript 文件?语句//= require_tree尝试读取...中的整个目录 -
Heroku 会在发现您尚未完成时为您预编译资产 - devcenter.heroku.com/articles/…
-
是的 - 我有一个 global.js.erb,里面有一个对 的调用,并且该文件位于 javascripts 目录中
-
好的不知道出了什么问题..从gem中删除了execjs、uglifer和coffeescript,做了捆绑安装并再次添加了它们,然后从资产中删除了erb文件(js和css)并rake预编译有效.. 那么如何在 css 和 erb 中使用 erb 呢?
标签: windows ruby-on-rails-3 heroku rake assets