I'm trying to create a gem that wraps d3.js, Source can be found at https://github.com/iblue/d3-rails
So when I include this gem in my Gemfile
gem "d3-rails", :git => "git://github.com/iblue/d3-rails.git"
And when I include the javascript in my application.js:
//=require d3
Then my asset compilation fails and my compiled application.js just contains
throw Error("Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT")
I am using Rails 3.1.3 and ruby-1.9.3-p125. jQuery uses exactly the same gem structure and it works. What am I doing wrong?
EDIT:
I also saw this question: Ruby 1.9 throwing javascript encoding error. This does not apply here, my file is valid 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
EDIT 2:
I also tried to insert some voodoo in my config/environment.rb
. It does not work:
# -*- 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!