When I try to use multibyte characters in my rails controller I get an
invalid multibyte characters error
(<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte
char (US-ASCII)).
Here is my controller:
contoller AdminController < ApplicationController
def read
@title = 'Заголовок страницы'
end
end
Here is my haml template extraction:
...
%title= @title
...
After I start the WEBrick server and go to
http://localhost:3000/admin/read I get the error. However, if I set #
encoding: utf-8 on top of the controller file the error disappear.
The question is how can I "officially" correct this error? How can I
maintain Rails to proper multibyte characters handling?
When I try to use multibyte characters in my rails controller I get an
invalid multibyte characters error
(<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte
char (US-ASCII)).
After I start the WEBrick server and go to
http://localhost:3000/admin/read I get the error. However, if I set #
encoding: utf-8 on top of the controller file the error disappear.
The question is how can I "officially" correct this error? How can I
maintain Rails to proper multibyte characters handling?
When I try to use multibyte characters in my rails controller I get an
invalid multibyte characters error
(<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte
char (US-ASCII)).
After I start the WEBrick server and go to
http://localhost:3000/admin/read I get the error. However, if I set #
encoding: utf-8 on top of the controller file the error disappear.
The question is how can I "officially" correct this error? How can I
maintain Rails to proper multibyte characters handling?
Is there a solution to this in 2010?
Self-reply: is there a solution to this in 2011?
I am running Rails 3.0.3 with Ruby 1.9.2 and it still fucks up.
- Make sure 'config.encoding = "utf-8"' is there in application.rb
file.
- Make sure you are using 'mysql2' gem
- Putting '# encoding: utf-8' on top of rake file.
- Above '<AppName>::Application.initialize!' line in environment.rb
file, add following two lines: