Encoding::CompatibilityError in rails

<%= link_to '注销', :controller => :user, :action => :logout %>

this raises Encoding::Compatibility exception, and when i try

<%= link_to '注销'.force_encoding('utf-8'), :controller => :user, :action => :logout %>

this didn’t help, either. but this works

  • ActiveRecord loads binary field incorrectly on Heroku, fine on OSX
  • Ruby on Rails flash messages in French
  • Rails 3 - How to handle PG Error incomplete multibyte character
  • rails paypal notify validate Japanese
  • Non ascii characters in link_to is causing the app to fail in internet explorer 9 in rails app
  • Fixtures: How to load utf-8 characters and convert to non utf-8 and save into database?
  • <a href="<%= url_for :controller => :user, :action => :logout>">注销</a>

    why ??? i just can’t figure out WHY this happends and HOW to fix it. any ideas?? thanks!!!
    ruby version 1.9, rails 2.3.5

  • Omniauth Facebook not returning email and gender rails 4
  • Sanitizing URL to prevent XSS in Rails
  • How do I manually get autotest to run on specific test files? Editing .autotest in rails app root has no effect
  • How to run Rails console in the test environment and load test_helper.rb?
  • Rails: “Stack level too deep” error when calling “id” primary key method
  • Match an option in select form with boolean values
  • One Solution collect form web for “Encoding::CompatibilityError in rails”

    I got similar errors before and it turned out that the file itself that contains the code is not using UTF8 encoding :(, so you’d better check the editor you are using as it might not be using UTF8 encoded files.

    Ruby is the best programming language in the world - Ruby on Rails.