我準備將我的Rails 3.1應用程序部署到生產環境中,並且因爲我正在使用資產管道I need to precompile my assets。然而,當我嘗試,我得到明顯涉及到編制的jQuery的錯誤:bundle exec rake assets:預編譯失敗,出現'unexpected token'
$ bundle exec rake --trace assets:precompile
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/adam/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /home/adam/.rvm/gems/[email protected]/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
399: unexpected token at '"/*!\u000a * jQuery JavaScript Library v1.7.1\u000a * http://jquery.com/\u000a *\u000a * Copyright 2011, John Resig\u000a * Dual licensed under the MIT or GPL Version 2 licenses.\u000a * http://jquery.org/license\u000a *\u000a * Includes Sizzle.js\u000a * http://sizzlejs.com/\u000a * Copyright 2011, The Dojo Foundation\u000a * Released under the MIT, BSD, and GPL Licenses.\u000a *\u000a * Date: Mon Nov 21 21:11:03 2011 -0500\u000a */\u000afunction addActiveScaffoldPageToHistory(a,b){if(typeof
[剪斷很多東西]
(in /data/music/RotC/eventbook/app/assets/javascripts/application.js)
/home/adam/.rvm/gems/[email protected]/gems/json-1.6.4/lib/json/common.rb:148:in `parse'
/home/adam/.rvm/gems/[email protected]/gems/json-1.6.4/lib/json/common.rb:148:in `parse'
/home/adam/.rvm/gems/[email protected]/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in `decode'
/home/adam/.rvm/gems/[email protected]/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode'
/home/adam/.rvm/gems/[email protected]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:61:in `extract_result'
/home/adam/.rvm/gems/[email protected]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:27:in `block in exec'
/home/adam/.rvm/gems/[email protected]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
/home/adam/.rvm/gems/[email protected]/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:26:in `exec'
[剪斷其它更多的東西]
這裏是我的application.js
:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//
// N.B. jQuery requires have to come before this:
//= require active_scaffold
我使用的是默認壓縮器,即uglifier
。
我發現,如果我改變config.assets.compress
在config/environments/production.rb
false
然後正常工作,但當然,我的應用程序將有更好的表現,如果我能想出辦法來保持它作爲true
。
我看過rake assets:precompile doesn't work (rails 3.1.1),我不認爲它是重複的,因爲錯誤是undefined: Unexpected token: operator (<)
。
任何想法?我隱約懷疑jQuery代碼中的unicode字符,但我不知道如何證明或反駁他們導致問題。
哪個js壓縮機是你用的?你的application.js中有什麼? – 2012-01-13 16:52:03
問題現在更新了這些。 – 2012-01-13 18:43:20