Library to monkey-patch ActiveRecord and add some Unicode awareness
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
LICENSE
README
active_record_encoding.gemspec

README

#
# Copyright (c) 2009, Michael H. Buselli
# See LICENSE for details.  All other rights reserved.
#

=======

Installation:

    gem install active_record_encoding --source=http://gems.cosine.org/

=======

#
# ActiveRecordEncoding — Module to make ActiveRecord aware of Unicode
# encoding issues.  It should be used only if the underlying database
# and its driver does not or cannot properly handle the encoding of the
# data it returns (usually as "ASCII-8BIT").  Most databases can
# properly encode data, however, so your first assumption should be that
# you do not need this software unless you really know you need it.
#
# ActiveRecordEncoding keeps a variables for each column and table
# where encoding is requested so it knows how the data is encoded in the
# database.  This variable is called its external_encoding.
#
# External encodings must be defined for each column or table where
# a translation is to occur, and this is done in the model definition:
#
#   class User < ActiveRecord::Base
#     external_encoding 'ISO-8859-1', :for => :comment
#     external_encoding 'ISO-8859-1', :for => [:first_name, :last_name]
#   end
#
# Data is converted to UTF-8 when passed to the user.
#
# When data is being saved back to the database, it is assumed that the
# data is in UTF-8, or on Ruby 1.9 if the String's encoding value is
# something other than "ASCII-8BIT" it uses that encoding.
#