Tôi đã sẵn sàng triển khai ứng dụng Rails 3.1 của mình vào sản xuất và vì tôi đang sử dụng đường dẫn nội dung, I need to precompile my assets. Tuy nhiên, khi tôi cố gắng này, tôi nhận được một lỗi rõ ràng liên quan đến biên soạn jQuery:tài sản thực thi gói: không biên dịch trước bằng `mã thông báo không mong muốn '
$ 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
[snip rất nhiều thứ]
(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'
[snip nhiều thứ hơn]
Dưới đây là application.js
của tôi :
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//
// N.B. jQuery requires have to come before this:
//= require active_scaffold
Tôi đang sử dụng máy nén mặc định, tức là uglifier
.
Tôi đã phát hiện ra rằng nếu tôi thay đổi config.assets.compress
để false
trong config/environments/production.rb
sau đó nó hoạt động tốt, nhưng tất nhiên ứng dụng của tôi sẽ thực hiện tốt hơn nếu tôi có thể tìm ra một cách để giữ nó như true
.
Tôi đã xem rake assets:precompile doesn't work (rails 3.1.1) và tôi không cho rằng đó là bản sao vì lỗi là undefined: Unexpected token: operator (<)
.
Bất kỳ ý tưởng nào? Tôi mơ hồ nghi ngờ về những ký tự unicode trong mã jQuery, nhưng tôi không chắc chắn làm thế nào để chứng minh hoặc bác bỏ rằng họ đang gây ra vấn đề.
bạn đang sử dụng máy nén js nào? Có gì trong application.js của bạn? –
Câu hỏi đã được cập nhật với những câu hỏi này. –