ERROR Encoding::CompatibilityError

Windows7 32bit
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
sinatra-1.3.1

my_test.rb

require ‘sinatra/base’

class MyTest < Sinatra::Base
get ‘/’ do
erb :index
end
end

if $0 == FILE
MyTest.run! :server => ‘webrick’, :port => 80
end

views/index.rb

Hello

Program is very simple!!
But!! Error Occurred!!
Help Me!!

[2011-12-09 13:13:00] ERROR Encoding::CompatibilityError: incompatible
character encodings: ASCII-8BIT and US-ASCII
C:/Ruby192/lib/ruby/1.9.1/webrick/accesslog.rb:50:in gsub' C:/Ruby192/lib/ruby/1.9.1/webrick/accesslog.rb:50:informat’
C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:166:in block in access_log' C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:165:ineach’
C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:165:in
access_log' C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:87:inrun’
C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in
start_thread’

Have you tried adding the magic encoding comment (see below) to the
top of all your Ruby files?

coding: utf-8

– Matma R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs