there are several places that can cause problems with utf-8 encoding.
but some tricks are to:
make sure that every file in your project is utf-8 based (if you
are using rad rails, this is simple to accomplish: mark your project,
select properties, in the “text-file-encoding” box, select “other:
utf-8”)
Be sure to put in your strange “å,ä,ö” characters in your files again
or you’ll get a mysql error, because it will change your “å,ä,ö” to a
“square” (unknown character)
in your databases.yml set for each server environment (in this
example “development” with mysql)
development:
adapter: mysql
encoding: utf8
set a before filter in your application controller
(application.rb):
class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset @headers[“Content-Type”] = “text/html; charset=utf-8”
end
end
be sure to set the encoding to utf-8 in your mysql (I’ve only used
mysql… so I don’t know about other databases) for every table. If you
use mySQL Administrator you can do like this: edit table, press the
“table option” tab, change charset to “utf8” and collation to
“utf8_general_ci”
class Fixtures
@@inserted_fixture_list ||= {}
alias :original_insert_fixtures :insert_fixtures
def insert_fixtures
return if @@inserted_fixture_list[values[0].class_name]
@@inserted_fixture_list[values[0].class_name] = true
unless ActiveRecord::Base.connection.select_one(“select 1 from
#{fixture_class_to_table_name(values[0].class_name)}”)
original_insert_fixtures
end
end
def delete_existing_fixtures() end
compute a fixture’s table name from its (known) class name
def fixture_class_to_table_name(class_name)
Inflector::tableize(class_name)
end
end
But I hate it to change Rails’ default behavior with code I don’t really
understand and might disturb Rails in a later release… :-/