1
votes

When I try to run heroku run rake db:migrate in my application, I get the following error

"\xC4" from ASCII-8BIT to UTF-8

with a stacktrace of

/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `write'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `puts'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `display_error_message'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:142:in `rescue in standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:132:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `'

I've tried setting encoding manually in config/environment.rb via

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

But it doesn't seem to help. The problem might be, that I'm using slim as a templating engine with many unicode characters directly in the templates, but I'm not sure if there's a better way of doing that.

1
If you are running on Ruby 1.9, you may have to set the encoding at the top of the template files with the irregular unicode characters like mentioned here. Try putting this line at the top of those files: # encoding: UTF-8Batkins
Here is a link to another very similar question that was asked on StackOverflow a while ago. This post might also help youBatkins

1 Answers

1
votes

Simply add this to the top of your file

# encoding: UTF-8

this error is frequent with migration when you insert data. For exemple I've got this with a simple migration adding Québec

Province.create(:name => 'Québec (Canada)')