windows - 抽取 Assets :precompile doesn't work (rails 3. 1.1)

标签 windows ruby-on-rails-3 heroku rake assets

我正在部署到 heroku,但我发现没有提供 css 文件(在 heroku 上也找不到它们)。

我读到我需要首先在本地执行 rake assets:precompile 但是当我这样做时我得到:

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 文件无法编译时仍然存在问题...

这似乎没有结束.. 谢谢

最佳答案

我一直在努力尝试部署到暂存服务器。对我有用的解决方案是确保您的 config/environments/[your_environment].rb 文件中包含以下内容:

config.assets.compress = false

默认情况下,压缩器在生产环境以外的环境中不可用,这就是预编译失败的原因。

关于windows - 抽取 Assets :precompile doesn't work (rails 3. 1.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7845585/

相关文章:

windows - 如何有效地检索目录中的文件数?

java - 单击我的按钮 Swing Java 后不显示任何内容

ruby-on-rails - 如何阻止 Rails 为没有 ID 的连接表调用 next_seq?

ruby-on-rails - Rails pdf-extract gem 有 sqlite 作为依赖项,但我使用 pg 因为 Heroku 需要它所以 bundle 安装失败

ruby-on-rails - rails : How to quickly secure entire site for development testing on Heroku?

python - 在 Virtualenv 中使用 Python 的 Pip

c# - 如何使用命令行回收远程机器上的应用程序池

c++ - 在文件扩展名和应用程序之间创建关联性?

ruby-on-rails - 如何运行单个 RSpec 测试?

ruby-on-rails - 在关联扩展中访问代理所有者的正确方法