I just tried to migrate one of my applications from ruby 1.8 to ruby 1.9
and get following error:
Showing app/views/layouts/application.html.erb where line #48 raised:
incompatible character encodings: ASCII-8BIT and UTF-8
48: <%= render :partial => 'layouts/menu' %>
I added "<%# coding: utf-8 %>" in application.html.erb and
layouts/_menu.rhtml but it still throws that error, anyone knows why?
I just tried to migrate one of my applications from ruby 1.8 to ruby 1.9
and get following error:
Showing app/views/layouts/application.html.erb where line #48 raised:
incompatible character encodings: ASCII-8BIT and UTF-8
48: <%= render :partial => 'layouts/menu' %>
I added "<%# coding: utf-8 %>" in application.html.erb and
In every of my 4 projects with this error it always throws it when a
special char is being displayed like ä, ö , ü, é, à etc.
It would be cool if I just need to paste some "# encoding: utf-8" or
something somewhere and it recognizes everything as utf-8, is there
anything like that I could do?
I've been struggling with the same issue a few times, and the solution
that worked for me was to use a different mysql driver: ruby-mysql
# in config/environment.rb:
config.gem 'ruby-mysql'
# or in Gemfile:
gem 'ruby-mysql'
The encoding must also be set in config/database.yml:
adapter: mysql
encoding: utf8
Hey,
First of all thanks but I tried what you said and well...
gem install ruby-mysql
config/environment.rb: added config.gem 'ruby-mysql'
config/database.yml: added adapter: mysql, encoding: utf8
But when I start the server I get following error:
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:
Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement
no such file to load -- ruby-mysql
...
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`require'Missing these required gems:
ruby-mysql
You're running:
ruby 1.9.1.378 at D:/ruby19/bin/ruby.exe
rubygems at D:/ruby19/lib/ruby/gems/1.9.1
Run `rake gems:install` to install the missing gems.
I of course tried rake gems:install but it didn't help. I also tried to
just uninstall the mysql gem but that didn't work either. Any idea?
If you have have hard coded strings in ruby code you should try
Mystring ="bla bla"
Mystring.force_encoding('ASCII-8BIT')
Before using it.
For database strings you should search for mysql to force encoding
(this is for db created with ruby 1.8)
Good luck
Heinz Strunk wrote:
I just tried to migrate one of my applications from ruby 1.8 to ruby 1.9
and get following error:
Showing app/views/layouts/application.html.erb where line #48 raised:
incompatible character encodings: ASCII-8BIT and UTF-8
Unfortunately not working:
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:
Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement
D:/ruby19/lib/ruby/site_ruby/1.9.1/rubygems/version.rb:186:in `strip!':
can't modify frozen string (RuntimeError)
from
D:/ruby19/lib/ruby/site_ruby/1.9.1/rubygems/version.rb:186:in
`initialize'
from
F:/NetBeansProjects/myproject/config/initializers/ruby_191_hacks.rb:12:in
`new'
from
F:/NetBeansProjects/myproject/config/initializers/ruby_191_hacks.rb:12:in
`<top (required)>'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in
`load'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in
`block in load_with_new_constant_marking'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in
`load_with_new_constant_marking'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:622:in
`block in load_application_initializers'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:621:in
`each'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:621:in
`load_application_initializers'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:176:in
`process'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:113:in
`run'
from F:/NetBeansProjects/myproject/config/environment.rb:10:in
`<top (required)>'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`require'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`block in require'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`require'
from
D:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/commands/server.rb:84:in
`<top (required)>'
from script/server:3:in `require'
from script/server:3:in `<main>'