utf 8 - Rails 3.1, Ruby 1.9.2-p180 and UTF-8 issues -


i'm having trouble utf-8 characters. here's db/seeds.rb

user.create(username: 'eml', first_name: '****', last_name: '****äck',              email: 'somemail@example.com', password: 'asdasd') 

my terminal (osx 10.5.8) set use utf-8, rails (according application.rb) set use utf-8. here's error:

$ rake db:seed rake aborted! /projects/***/db/seeds.rb:8: invalid multibyte char (us-ascii) /projects/***/db/seeds.rb:8: invalid multibyte char (us-ascii) /projects/***/db/seeds.rb:8: syntax error, unexpected $end, expecting ')' ...ame: '****', last_name: '****äck',  ...                               ^  tasks: top => db:seed (see full trace running task --trace) 

add line # encoding: utf-8 on top of seeds.rb file , ruby file use spécials chars

i recommed adding encoding.default_external = "utf-8" config.ru file , in config/environment.rb encoding templating

and can add "".force_encoding('utf-8) string pose problems.

update :

add full line on config.ru :

# not override -e option or lang , apply ruby > 1.9
if object.const_defined?(:encoding) && !env['lang'] && !env['rubyopt'].include?('-e')
encoding.default_internal = 'utf-8'
encoding.default_external = 'utf-8'
end

source


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -