ibl*_*lue 7 javascript rubygems ruby-on-rails ruby-on-rails-3.1 asset-pipeline
我正在尝试创建一个包装d3.js的gem,Source可以在https://github.com/iblue/d3-rails找到
所以当我在我的Gemfile中包含这个gem时
gem "d3-rails", :git => "git://github.com/iblue/d3-rails.git"
Run Code Online (Sandbox Code Playgroud)
当我在我的application.js中包含javascript时:
//=require d3
Run Code Online (Sandbox Code Playgroud)
然后我的资产编译失败,我编译的application.js只包含
throw Error("Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT")
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 3.1.3和ruby-1.9.3-p125.jQuery使用完全相同的gem结构,它的工作原理.我究竟做错了什么?
编辑:
我也看到了这个问题:Ruby 1.9抛出javascript编码错误.这不适用于此,我的文件是有效的UTF-8:
ruby-1.9.3-p125 :001 > d = File.read("./d3.js")
=> [...]
ruby-1.9.3-p125 :002 > d.encoding
=> #<Encoding:UTF-8>
ruby-1.9.3-p125 :003 > d.valid_encoding?
=> true
Run Code Online (Sandbox Code Playgroud)
编辑2:
我也尝试在我的插页中插入一些伏都教config/environment.rb
.这是行不通的:
# -*- encoding : utf-8 -*-
# Load the rails application
require File.expand_path('../application', __FILE__)
# --------- VOODOO BEGINS HERE -----------------
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# --------- END VOODO --------------------------
# Initialize the rails application
Ratecode::Application.initialize!
Run Code Online (Sandbox Code Playgroud)
来自WEBrick服务器的错误还是其他什么?有用rake assets:precompile
吗?(不要忘记清除资产后)
如果后者失败,请仔细检查$ LANG环境变量的值是UTF-8(with env
).如果rake任务有效但应用程序失败则可能是服务器env vars.
归档时间: |
|
查看次数: |
2287 次 |
最近记录: |