Note that there are some explanatory texts on larger screens.

plurals
  1. POAsset pipeline encoding problems (UTF-8 vs. ASCII-8BIT) with external gem
    primarykey
    data
    text
    <p>I'm trying to create a gem that wraps d3.js, Source can be found at <a href="https://github.com/iblue/d3-rails" rel="nofollow noreferrer">https://github.com/iblue/d3-rails</a></p> <p>So when I include this gem in my Gemfile</p> <pre><code>gem "d3-rails", :git =&gt; "git://github.com/iblue/d3-rails.git" </code></pre> <p>And when I include the javascript in my application.js:</p> <pre><code>//=require d3 </code></pre> <p>Then my asset compilation fails and my compiled application.js just contains</p> <pre><code>throw Error("Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT") </code></pre> <p>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?</p> <p><strong>EDIT</strong>:</p> <p>I also saw this question: <a href="https://stackoverflow.com/questions/9116752/ruby-1-9-throwing-javascript-encoding-error">Ruby 1.9 throwing javascript encoding error</a>. This does not apply here, my file is valid UTF-8:</p> <pre><code>ruby-1.9.3-p125 :001 &gt; d = File.read("./d3.js") =&gt; [...] ruby-1.9.3-p125 :002 &gt; d.encoding =&gt; #&lt;Encoding:UTF-8&gt; ruby-1.9.3-p125 :003 &gt; d.valid_encoding? =&gt; true </code></pre> <p><strong>EDIT 2</strong>:</p> <p>I also tried to insert some voodoo in my <code>config/environment.rb</code>. It does not work:</p> <pre><code># -*- 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! </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload