2016-02-19   erb   ruby   web 

erbでincompatible character encodingsが出たときの対処(encoding UTF-8を入れる)

環境

Before

<%
load 'common/author.rb'
COLOR_PRIMARY = '#559fbf'
URL = 'http://girl1.hyuki.net/'
...
%>
...

Error

$ erb index.erb > index.html
... in `concat': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)

After

<%# encoding: UTF-8 %>
<%
load 'common/author.rb'
COLOR_PRIMARY = '#559fbf'
URL = 'http://girl1.hyuki.net/'
...
%>
...

関連

 2016-02-19   erb   ruby   web