Index: activeresource/Rakefile
===================================================================
--- activeresource/Rakefile	(revision 8514)
+++ activeresource/Rakefile	(working copy)
@@ -1,10 +1,11 @@
 require 'rubygems'
-require 'rake'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/packagetask'
 require 'rake/gempackagetask'
 require 'rake/contrib/rubyforgepublisher'
+
 require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version')
 
 PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
Index: actionmailer/test/mail_service_test.rb
===================================================================
--- actionmailer/test/mail_service_test.rb	(revision 8514)
+++ actionmailer/test/mail_service_test.rb	(working copy)
@@ -548,7 +548,9 @@
 The body
 EOF
     mail = TMail::Mail.parse(msg)
-    assert_equal "testing testing \326\244", mail.subject
+    expected = "testing testing \326\244"
+    expected.force_encoding 'utf-8' if expected.respond_to? :force_encoding
+    assert_equal expected, mail.subject
     assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject
   end
 
Index: actionmailer/test/quoting_test.rb
===================================================================
--- actionmailer/test/quoting_test.rb	(revision 8514)
+++ actionmailer/test/quoting_test.rb	(working copy)
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
 require "#{File.dirname(__FILE__)}/abstract_unit"
 require 'tmail'
 require 'tempfile'
@@ -38,11 +40,14 @@
   def test_unqoute_iso
     a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?=" 
     b = TMail::Unquoter.unquote_and_convert_to(a, 'iso-8859-1')
-    assert_equal "Brosch\374re Rand", b
+    expected = "Brosch\374re Rand"
+    expected.force_encoding 'iso-8859-1' if expected.respond_to? :force_encoding
+    assert_equal expected, b
   end
     
   def test_quote_multibyte_chars
     original = "\303\246 \303\270 and \303\245"
+    original.force_encoding nil if original.respond_to? :force_encoding
 
     result = execute_in_sandbox(<<-CODE)
       $:.unshift(File.dirname(__FILE__) + "/../lib/")
Index: actionmailer/Rakefile
===================================================================
--- actionmailer/Rakefile	(revision 8514)
+++ actionmailer/Rakefile	(working copy)
@@ -1,10 +1,11 @@
 require 'rubygems'
-require 'rake'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/packagetask'
 require 'rake/gempackagetask'
 require 'rake/contrib/rubyforgepublisher'
+
 require File.join(File.dirname(__FILE__), 'lib', 'action_mailer', 'version')
 
 PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
Index: actionmailer/lib/action_mailer/helpers.rb
===================================================================
--- actionmailer/lib/action_mailer/helpers.rb	(revision 8514)
+++ actionmailer/lib/action_mailer/helpers.rb	(working copy)
@@ -93,9 +93,9 @@
           begin
             child.master_helper_module = Module.new
             child.master_helper_module.send! :include, master_helper_module
-            child.helper child.name.underscore
+            child.helper child.name.to_s.underscore
           rescue MissingSourceFile => e
-            raise unless e.is_missing?("helpers/#{child.name.underscore}_helper")
+            raise unless e.is_missing?("helpers/#{child.name.to_s.underscore}_helper")
           end
         end        
     end
Index: actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb
===================================================================
--- actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb	(revision 8514)
+++ actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb	(working copy)
@@ -91,7 +91,7 @@
     }
 
     def self.decode( str, encoding = nil )
-      encoding ||= (OUTPUT_ENCODING[$KCODE] || 'j')
+      encoding ||= (OUTPUT_ENCODING[RUBY_VERSION >= '1.9' ? nil : $KCODE] || 'j')
       opt = '-m' + encoding
       str.gsub(ENCODED_WORDS) {|s| NKF.nkf(opt, s) }
     end
@@ -193,7 +193,7 @@
 
     def initialize( dest = nil, encoding = nil, eol = "\r\n", limit = nil )
       @f = StrategyInterface.create_dest(dest)
-      @opt = OPTIONS[$KCODE]
+      @opt = OPTIONS[RUBY_VERSION >= '1.9' ? nil : $KCODE]
       @eol = eol
       @preserve_quotes = true
       reset
@@ -370,8 +370,8 @@
       i = 0
       types.each_byte do |t|
         case t
-        when ?a then add_text strs[i]
-        when ?s then add_lwsp strs[i]
+        when 'a'.ord then add_text strs[i]
+        when 's'.ord then add_lwsp strs[i]
         else
           raise "TMail FATAL: unknown flag: #{t.chr}"
         end
Index: actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/utils.rb
===================================================================
--- actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/utils.rb	(revision 8514)
+++ actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/utils.rb	(working copy)
@@ -239,7 +239,7 @@
     }
 
     def to_kcode( str )
-      flag = NKF_FLAGS[$KCODE] or return str
+      flag = NKF_FLAGS[RUBY_VERSION >= '1.9' ? nil : $KCODE] or return str
       NKF.nkf(flag, str)
     end
 
@@ -248,7 +248,7 @@
     def decode_RFC2231( str )
       m = RFC2231_ENCODED.match(str) or return str
       begin
-        NKF.nkf(NKF_FLAGS[$KCODE],
+        NKF.nkf(NKF_FLAGS[RUBY_VERSION >= '1.9' ? nil : $KCODE],
         m.post_match.gsub(/%[\da-f]{2}/in) {|s| s[1,2].hex.chr })
       rescue
         m.post_match.gsub(/%[\da-f]{2}/in, "")
Index: actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/scanner_r.rb
===================================================================
--- actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/scanner_r.rb	(revision 8514)
+++ actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/scanner_r.rb	(working copy)
@@ -88,7 +88,7 @@
         domlit_without_iso2022,
         comment_without_iso2022
       ]
-    PATTERN_TABLE['NONE'] =
+    PATTERN_TABLE['NONE'] = PATTERN_TABLE[nil] =
       [
         /\A[#{atomchars}]+/n,
         /\A[#{tokenchars}]+/n,
@@ -107,7 +107,8 @@
       @received  = (scantype == :RECEIVED)
       @is_mime_header = MIME_HEADERS[scantype]
 
-      atom, token, @quoted_re, @domlit_re, @comment_re = PATTERN_TABLE[$KCODE]
+      atom, token, @quoted_re, @domlit_re, @comment_re =
+        PATTERN_TABLE[RUBY_VERSION >= '1.9' ? nil : $KCODE]
       @word_re = (MIME_HEADERS[scantype] ? token : atom)
     end
 
@@ -147,34 +148,34 @@
 
         if s = readstr(@word_re)
           if @is_mime_header
-            yield :TOKEN, s
+            yield [:TOKEN, s]
           else
             # atom
             if /\A\d+\z/ === s
-              yield :DIGIT, s
+              yield [:DIGIT, s]
             elsif @received
-              yield RECV_TOKEN[s.downcase] || :ATOM, s
+              yield RECV_TOKEN[s.downcase] || [:ATOM, s]
             else
-              yield :ATOM, s
+              yield [:ATOM, s]
             end
           end
 
         elsif skip(/\A"/)
-          yield :QUOTED, scan_quoted_word()
+          yield [:QUOTED, scan_quoted_word()]
 
         elsif skip(/\A\[/)
-          yield :DOMLIT, scan_domain_literal()
+          yield [:DOMLIT, scan_domain_literal()]
 
         elsif skip(/\A\(/)
           @comments.push scan_comment()
 
         else
           c = readchar()
-          yield c, c
+          yield [c, c]
         end
       end
 
-      yield false, '$'
+      yield [false, '$']
     end
 
     def scan_quoted_word
Index: activesupport/test/multibyte_chars_test.rb
===================================================================
--- activesupport/test/multibyte_chars_test.rb	(revision 8514)
+++ activesupport/test/multibyte_chars_test.rb	(working copy)
@@ -4,7 +4,7 @@
   class CharsTest < Test::Unit::TestCase
     def test_chars_returns_self
       str = 'abc'
-      assert_equal str.object_id, str.chars.object_id
+      assert_equal str.object_id, str.unicode_safe.object_id
     end
   end
 else
@@ -25,7 +25,9 @@
     @s.each do |t, s|
       assert s.respond_to?(:chars), "All string should have the chars method (#{t})"
       assert s.respond_to?(:to_s), "All string should have the to_s method (#{t})"
-      assert_kind_of ActiveSupport::Multibyte::Chars, s.chars, "#chars should return an instance of Chars (#{t})"
+      if RUBY_VERSION < '1.9'
+        assert_kind_of ActiveSupport::Multibyte::Chars, s.chars, "#chars should return an instance of Chars (#{t})"
+      end
     end
   end
   
Index: activesupport/test/core_ext/time_ext_test.rb
===================================================================
--- activesupport/test/core_ext/time_ext_test.rb	(revision 8514)
+++ activesupport/test/core_ext/time_ext_test.rb	(working copy)
@@ -277,7 +277,7 @@
   def test_next_week
     with_timezone 'US/Eastern' do
       assert_equal Time.local(2005,2,28), Time.local(2005,2,22,15,15,10).next_week
-      assert_equal Time.local(2005,2,29), Time.local(2005,2,22,15,15,10).next_week(:tuesday)
+      assert_equal Time.local(2005,3,1), Time.local(2005,2,22,15,15,10).next_week(:tuesday)
       assert_equal Time.local(2005,3,4), Time.local(2005,2,22,15,15,10).next_week(:friday)
       assert_equal Time.local(2006,10,30), Time.local(2006,10,23,0,0,0).next_week
       assert_equal Time.local(2006,11,1), Time.local(2006,10,23,0,0,0).next_week(:wednesday)
Index: activesupport/Rakefile
===================================================================
--- activesupport/Rakefile	(revision 8514)
+++ activesupport/Rakefile	(working copy)
@@ -1,6 +1,9 @@
+require 'rubygems'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/gempackagetask'
+
 require File.join(File.dirname(__FILE__), 'lib', 'active_support', 'version')
 
 PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
Index: activesupport/lib/active_support/core_ext/string/access.rb
===================================================================
--- activesupport/lib/active_support/core_ext/string/access.rb	(revision 8514)
+++ activesupport/lib/active_support/core_ext/string/access.rb	(working copy)
@@ -1,57 +1,114 @@
 module ActiveSupport #:nodoc:
   module CoreExtensions #:nodoc:
     module String #:nodoc:
-      # Makes it easier to access parts of a string, such as specific characters and substrings.
-      module Access
-        # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
-        #
-        # Examples: 
-        #   "hello".at(0)  # => "h"
-        #   "hello".at(4)  # => "o"
-        #   "hello".at(10) # => nil
-        def at(position)
-          chars[position, 1].to_s
+      if RUBY_VERSION < '1.9'
+        # Makes it easier to access parts of a string, such as specific characters and substrings.
+        # (Ruby 1.8 version)
+        module Access
+          # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".at(0)  # => "h"
+          #   "hello".at(4)  # => "o"
+          #   "hello".at(10) # => nil
+          def at(position)
+            chars[position, 1].to_s
+          end
+          
+          # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".from(0)  # => "hello"
+          #   "hello".from(2)  # => "llo"
+          #   "hello".from(10) # => nil
+          def from(position)
+            chars[position..-1].to_s
+          end
+          
+          # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".to(0)  # => "h"
+          #   "hello".to(2)  # => "hel"
+          #   "hello".to(10) # => "hello"
+          def to(position)
+            chars[0..position].to_s
+          end
+          
+          # Returns the first character of the string or the first +limit+ characters.
+          #
+          # Examples: 
+          #   "hello".first     # => "h"
+          #   "hello".first(2)  # => "he"
+          #   "hello".first(10) # => "hello"
+          def first(limit = 1)
+            chars[0..(limit - 1)].to_s
+          end
+          
+          # Returns the last character of the string or the last +limit+ characters.
+          #
+          # Examples: 
+          #   "hello".last     # => "o"
+          #   "hello".last(2)  # => "lo"
+          #   "hello".last(10) # => "hello"
+          def last(limit = 1)
+            (chars[(-limit)..-1] || self).to_s
+          end
         end
-        
-        # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
-        #
-        # Examples: 
-        #   "hello".from(0)  # => "hello"
-        #   "hello".from(2)  # => "llo"
-        #   "hello".from(10) # => nil
-        def from(position)
-          chars[position..-1].to_s
+      else
+        # Makes it easier to access parts of a string, such as specific characters and substrings.
+        # (Ruby 1.9 version)
+        module Access
+          # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".at(0)  # => "h"
+          #   "hello".at(4)  # => "o"
+          #   "hello".at(10) # => nil
+          def at(position)
+            self[position]
+          end
+          
+          # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".from(0)  # => "hello"
+          #   "hello".from(2)  # => "llo"
+          #   "hello".from(10) # => nil
+          def from(position)
+            self[position..-1]
+          end
+          
+          # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
+          #
+          # Examples: 
+          #   "hello".to(0)  # => "h"
+          #   "hello".to(2)  # => "hel"
+          #   "hello".to(10) # => "hello"
+          def to(position)
+            self[0..position]
+          end
+          
+          # Returns the first character of the string or the first +limit+ characters.
+          #
+          # Examples: 
+          #   "hello".first     # => "h"
+          #   "hello".first(2)  # => "he"
+          #   "hello".first(10) # => "hello"
+          def first(limit = 1)
+            self[0...limit]
+          end
+          
+          # Returns the last character of the string or the last +limit+ characters.
+          #
+          # Examples: 
+          #   "hello".last     # => "o"
+          #   "hello".last(2)  # => "lo"
+          #   "hello".last(10) # => "hello"
+          def last(limit = 1)
+            self[(-limit)..-1] || self
+          end
         end
-        
-        # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
-        #
-        # Examples: 
-        #   "hello".to(0)  # => "h"
-        #   "hello".to(2)  # => "hel"
-        #   "hello".to(10) # => "hello"
-        def to(position)
-          chars[0..position].to_s
-        end
-
-        # Returns the first character of the string or the first +limit+ characters.
-        #
-        # Examples: 
-        #   "hello".first     # => "h"
-        #   "hello".first(2)  # => "he"
-        #   "hello".first(10) # => "hello"
-        def first(limit = 1)
-          chars[0..(limit - 1)].to_s
-        end
-        
-        # Returns the last character of the string or the last +limit+ characters.
-        #
-        # Examples: 
-        #   "hello".last     # => "o"
-        #   "hello".last(2)  # => "lo"
-        #   "hello".last(10) # => "hello"
-        def last(limit = 1)
-          (chars[(-limit)..-1] || self).to_s
-        end
       end
     end
   end
Index: activesupport/lib/active_support/core_ext/string/unicode.rb
===================================================================
--- activesupport/lib/active_support/core_ext/string/unicode.rb	(revision 8514)
+++ activesupport/lib/active_support/core_ext/string/unicode.rb	(working copy)
@@ -31,7 +31,9 @@
           def chars
             ActiveSupport::Multibyte::Chars.new(self)
           end
-
+          
+          alias unicode_safe chars
+          
           # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
           # them), returns false otherwise.
           def is_utf8?
@@ -40,10 +42,11 @@
         end
       else
         module Unicode #:nodoc:
-          def chars
+          
+          def unicode_safe
             self
           end
-
+          
           def is_utf8?
             case encoding
               when Encoding::UTF_8
Index: activesupport/lib/active_support/core_ext/object/extending.rb
===================================================================
--- activesupport/lib/active_support/core_ext/object/extending.rb	(revision 8514)
+++ activesupport/lib/active_support/core_ext/object/extending.rb	(working copy)
@@ -29,7 +29,7 @@
     object.extended_by.each { |mod| extend mod }
   end
 
-  unless defined? instance_exec # 1.9
+  unless defined? instance_exec # Ruby 1.9
     module InstanceExecMethods #:nodoc:
     end
     include InstanceExecMethods
Index: activerecord/test/fixtures_test.rb
===================================================================
--- activerecord/test/fixtures_test.rb	(revision 8514)
+++ activerecord/test/fixtures_test.rb	(working copy)
@@ -474,7 +474,7 @@
 
     load_extra_fixture('posts')
     assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'posts')
-    self.class.setup_fixture_accessors('posts')
+    self.class.setup_fixture_accessors(%w'posts')
     assert_equal 'Welcome to the weblog', posts(:welcome).title
   end
 end
Index: activerecord/test/base_test.rb
===================================================================
--- activerecord/test/base_test.rb	(revision 8514)
+++ activerecord/test/base_test.rb	(working copy)
@@ -1240,7 +1240,7 @@
     
     assert_kind_of Topic, topic
     assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars"
-  end
+  end if RUBY_VERSION < '1.9'
   
   def test_class_level_destroy
     should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world")
Index: activerecord/test/validations_test.rb
===================================================================
--- activerecord/test/validations_test.rb	(revision 8514)
+++ activerecord/test/validations_test.rb	(working copy)
@@ -851,7 +851,7 @@
 
   def test_validates_length_of_using_minimum_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :minimum => 5
+      Topic.validates_length_of :title, :minimum => 5, :encoding => 'utf-8'
 
       t = Topic.create("title" => "一二三四五", "content" => "whatever")
       assert t.valid?
@@ -865,7 +865,7 @@
 
   def test_validates_length_of_using_maximum_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :maximum => 5
+      Topic.validates_length_of :title, :maximum => 5, :encoding => 'utf-8'
 
       t = Topic.create("title" => "一二三四五", "content" => "whatever")
       assert t.valid?
@@ -879,7 +879,7 @@
 
   def test_validates_length_of_using_within_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of(:title, :content, :within => 3..5)
+      Topic.validates_length_of :title, :content, :within => 3..5, :encoding => 'utf-8'
 
       t = Topic.new("title" => "一二", "content" => "12三四五六七")
       assert !t.valid?
@@ -893,7 +893,8 @@
 
   def test_optionally_validates_length_of_using_within_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true
+      Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true,
+        :encoding => 'utf-8'
 
       t = Topic.create('title' => '一二三', 'content' => '一二三四五')
       assert t.valid?
@@ -905,7 +906,8 @@
 
   def test_optionally_validates_length_of_using_within_on_create_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "長すぎます: %d"
+      Topic.validates_length_of :title, :content, :within => 5..10, :on => :create,
+        :too_long => "長すぎます: %d", :encoding => 'utf-8'
 
       t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever")
       assert !t.save
@@ -914,7 +916,7 @@
 
       t.title = "一二三四五六七八九"
       assert t.save
-
+      
       t.title = "一二3"
       assert t.save
 
@@ -928,7 +930,8 @@
 
   def test_optionally_validates_length_of_using_within_on_update_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "短すぎます: %d"
+      Topic.validates_length_of :title, :content, :within => 5..10, :on => :update,
+        :too_short => "短すぎます: %d", :encoding => 'utf-8'
 
       t = Topic.create("title" => "一二三4", "content" => "whatever")
       assert !t.save
@@ -951,7 +954,7 @@
 
   def test_validates_length_of_using_is_utf8
     with_kcode('UTF8') do
-      Topic.validates_length_of :title, :is => 5
+      Topic.validates_length_of :title, :is => 5, :encoding => 'utf-8'
 
       t = Topic.create("title" => "一二345", "content" => "whatever")
       assert t.valid?
Index: activerecord/Rakefile
===================================================================
--- activerecord/Rakefile	(revision 8514)
+++ activerecord/Rakefile	(working copy)
@@ -1,10 +1,11 @@
 require 'rubygems'
-require 'rake'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/packagetask'
 require 'rake/gempackagetask'
 require 'rake/contrib/rubyforgepublisher'
+
 require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version')
 
 PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
Index: activerecord/lib/active_record/validations.rb
===================================================================
--- activerecord/lib/active_record/validations.rb	(revision 8514)
+++ activerecord/lib/active_record/validations.rb	(working copy)
@@ -348,7 +348,7 @@
       def evaluate_condition(condition, record)
         case condition
           when Symbol; record.send(condition)
-          when String; eval(condition, record.send(:binding))
+          when String; record.instance_eval(condition)
           else
             if condition_block?(condition)
               condition.call(record)
@@ -586,9 +586,15 @@
             too_long  = options[:too_long]  % option_value.end
 
             validates_each(attrs, options) do |record, attr, value|
-              if value.nil? or value.split(//).size < option_value.begin
+              if value.respond_to?(:encoding)
+                value = value.dup.force_encoding options[:encoding]
+                value_char_size = value.size
+              elsif value
+                value_char_size = value.split(//).size
+              end
+              if value.nil? or value_char_size < option_value.begin
                 record.errors.add(attr, too_short)
-              elsif value.split(//).size > option_value.end
+              elsif value_char_size > option_value.end
                 record.errors.add(attr, too_long)
               end
             end
@@ -603,7 +609,13 @@
 
             validates_each(attrs, options) do |record, attr, value|
               if value.kind_of?(String)
-                record.errors.add(attr, message) unless !value.nil? and value.split(//).size.method(validity_checks[option])[option_value]
+                if value.respond_to?(:encoding)
+                  value = value.dup.force_encoding options[:encoding]
+                  value_char_size = value.size
+                elsif value
+                  value_char_size = value.split(//).size
+                end
+                record.errors.add(attr, message) unless !value.nil? and value_char_size.method(validity_checks[option])[option_value]
               else
                 record.errors.add(attr, message) unless !value.nil? and value.size.method(validity_checks[option])[option_value]
               end
Index: activerecord/lib/active_record/vendor/mysql.rb
===================================================================
--- activerecord/lib/active_record/vendor/mysql.rb	(revision 8514)
+++ activerecord/lib/active_record/vendor/mysql.rb	(working copy)
@@ -117,6 +117,8 @@
 
     a = read
     @protocol_version = a.slice!(0)
+    @protocol_version = @protocol_version.ord unless @protocol_version.is_a? Fixnum
+
     @server_version, a = a.split(/\0/,2)
     @thread_id, @scramble_buff = a.slice!(0,13).unpack("La8")
     if a.size >= 2 then
@@ -159,7 +161,7 @@
 
   def handle_auth_fallback(pkt, passwd)
     # A packet like this means that we need to send an old-format password
-    if pkt.size == 1 and pkt[0] == 254 and
+    if pkt.size == 1 and pkt[0,1].ord == 254 and
        @server_capabilities & CLIENT_SECURE_CONNECTION != 0 then
       data = scramble(passwd, @scramble_buff, @protocol_version == 9)
       write data + "\0"
@@ -359,9 +361,9 @@
 
   def read_one_row(field_count)
     data = read
-    if data[0] == 254 and data.length == 1 ## EOF
+    if data[0,1].ord == 254 and data.length == 1 ## EOF
       return
-    elsif data[0] == 254 and data.length == 5
+    elsif data[0,1].ord == 254 and data.length == 5
       return
     end
     rec = []
@@ -380,7 +382,7 @@
     if @status == :STATUS_USE_RESULT then
       loop do
 	data = read
-	break if data[0] == 254 and data.length == 1
+	break if data[0,1].ord == 254 and data.length == 1
       end
       @status = :STATUS_READY
     end
@@ -408,6 +410,7 @@
       @insert_id = get_length(data, true)
       if @server_capabilities & CLIENT_TRANSACTIONS != 0 then
 	a = data.slice!(0,2)
+	a = a.unpack('C*') unless a[0].is_a? Fixnum
 	@server_status = a[0]+a[1]*256
       end
       if data.size > 0 and get_length(data) then
@@ -432,8 +435,11 @@
       if @pre_411
         table = org_table = f[0]
         name = f[1]
+        f[2] = f[2].unpack('C*') unless f[2][0].is_a? Fixnum
         length = f[2][0]+f[2][1]*256+f[2][2]*256*256
+        f[3] = f[3].unpack('C*') unless f[3][0].is_a? Fixnum
         type = f[3][0]
+        f[4] = f[4].unpack('C*') unless f[4][0].is_a? Fixnum
         if long_flag_protocol then
           flags = f[4][0]+f[4][1]*256
           decimals = f[4][2]
@@ -450,6 +456,7 @@
         org_table = f[3]
         name = f[4]
         org_name = f[5]
+        f[6] = f[6].unpack('C*') unless f[6][2].is_a? Fixnum
         length = f[6][2]+f[6][3]*256+f[6][4]*256*256
         type = f[6][6]
         flags = f[6][7]+f[6][8]*256
@@ -472,18 +479,21 @@
 
   def get_length(data, longlong=nil)
     return if data.length == 0
-    c = data.slice!(0)
-    case c
+    c = data.slice!(0,1)
+    case c.ord
     when 251
       return nil
     when 252
       a = data.slice!(0,2)
+      a = a.unpack('C*') unless a[0].is_a? Fixnum
       return a[0]+a[1]*256
     when 253
       a = data.slice!(0,3)
+      a = a.unpack('C*') unless a[0].is_a? Fixnum
       return a[0]+a[1]*256+a[2]*256**2
     when 254
       a = data.slice!(0,8)
+      a = a.unpack('C*') unless a[0].is_a? Fixnum
       if longlong then
 	return a[0]+a[1]*256+a[2]*256**2+a[3]*256**3+
 	  a[4]*256**4+a[5]*256**5+a[6]*256**6+a[7]*256**7
@@ -491,7 +501,7 @@
 	return a[0]+a[1]*256+a[2]*256**2+a[3]*256**3
       end
     else
-      c
+      c.ord
     end
   end
 
@@ -511,10 +521,11 @@
     unless @net then
       error Error::CR_SERVER_GONE_ERROR
     end
-    a = @net.read
-    if a[0] == 255 then
-      if a.length > 3 then
-	@errno = a[1]+a[2]*256
+    a_bytes = a = @net.read
+    a_bytes = a_bytes.unpack('C*') unless a_bytes[0].is_a? Fixnum
+    if a_bytes[0] == 255 then
+      if a_bytes.length > 3 then
+	@errno = a_bytes[1]+a_bytes[2]*256
 	@error = a[3 .. -1]
       else
 	@errno = Error::CR_UNKNOWN_ERROR
@@ -549,7 +560,9 @@
     return "" if password == nil or password == ""
     raise "old version password is not implemented" if old_ver
     hash_pass = hash_password password
+    hash_pass = hash_pass.unpack('C*') unless hash_pass[0].is_a? Fixnum
     hash_message = hash_password message.slice(0,SCRAMBLE_LENGTH_323)
+    hash_message = hash_message.unpack('C*') unless hash_message[0].is_a? Fixnum
     rnd = Random::new hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]
     to = []
     1.upto(SCRAMBLE_LENGTH_323) do
@@ -566,7 +579,7 @@
     s1 = Digest::SHA1.digest(password)
     s2 = Digest::SHA1.digest(s1)
     x = Digest::SHA1.digest(message + s2)
-    (0..s1.length - 1).each {|i| buf.push(s1[i] ^ x[i])}
+    (0..s1.length - 1).each {|i| buf.push(s1[i,1].ord ^ x[i,1].ord)}
     buf.pack("C*")
   end
 
@@ -1091,13 +1104,15 @@
       len = nil
       @sock.sync = false
       while len == nil or len == MAX_PACKET_LENGTH do
+	raise if @sock.eof? && RUBY_VERSION >= '1.9'  # Ruby 1.9 bug?
 	a = @sock.read(4)
+	a = a.unpack('C*') unless a[0].is_a? Fixnum
 	len = a[0]+a[1]*256+a[2]*256*256
 	pkt_nr = a[3]
 	if @pkt_nr != pkt_nr then
 	  raise "Packets out of order: #{@pkt_nr}<>#{pkt_nr}"
 	end
-	@pkt_nr = @pkt_nr + 1 & 0xff
+	@pkt_nr = (@pkt_nr + 1) & 0xff
 	buf << @sock.read(len)
       end
       @sock.sync = true
@@ -1113,6 +1128,7 @@
       end
       @sock.sync = false
       ptr = 0
+      data.force_encoding nil if data.respond_to? :force_encoding
       while data.length >= MAX_PACKET_LENGTH do
 	@sock.write Net::int3str(MAX_PACKET_LENGTH)+@pkt_nr.chr+data[ptr, MAX_PACKET_LENGTH]
 	@pkt_nr = @pkt_nr + 1 & 0xff
Index: activerecord/lib/active_record/associations/association_proxy.rb
===================================================================
--- activerecord/lib/active_record/associations/association_proxy.rb	(revision 8514)
+++ activerecord/lib/active_record/associations/association_proxy.rb	(working copy)
@@ -5,7 +5,7 @@
       alias_method :proxy_respond_to?, :respond_to?
       alias_method :proxy_extend, :extend
       delegate :to_param, :to => :proxy_target
-      instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_)/ }
+      instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|object_id)/ }
 
       def initialize(owner, reflection)
         @owner, @reflection = owner, reflection
Index: activerecord/lib/active_record/associations/association_collection.rb
===================================================================
--- activerecord/lib/active_record/associations/association_collection.rb	(revision 8514)
+++ activerecord/lib/active_record/associations/association_collection.rb	(working copy)
@@ -161,7 +161,9 @@
           if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
             super
           else
-            @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) }
+            @reflection.klass.send(:with_scope, construct_scope) do
+              @reflection.klass.send(method, *args, &block)
+            end
           end
         end
 
Index: activerecord/lib/active_record/associations.rb
===================================================================
--- activerecord/lib/active_record/associations.rb	(revision 8514)
+++ activerecord/lib/active_record/associations.rb	(working copy)
@@ -1383,6 +1383,10 @@
         def create_extension_modules(association_id, block_extension, extensions)
           if block_extension
             extension_module_name = "#{self.to_s}#{association_id.to_s.camelize}AssociationExtension"
+            if RUBY_VERSION >= '1.9'
+              warn "Ruby 1.9 bug: Association Proxy Extension won't work: " + extension_module_name
+              extension = nil
+            end
 
             silence_warnings do
               Object.const_set(extension_module_name, Module.new(&block_extension))
Index: activerecord/lib/active_record/fixtures.rb
===================================================================
--- activerecord/lib/active_record/fixtures.rb	(revision 8514)
+++ activerecord/lib/active_record/fixtures.rb	(working copy)
@@ -558,7 +558,11 @@
     now = now.to_s(:db)
 
     # allow a standard key to be used for doing defaults in YAML
-    delete(assoc("DEFAULTS"))
+    if is_a? ::Hash
+      delete("DEFAULTS")
+    else
+      delete(assoc("DEFAULTS"))
+    end
 
     # track any join tables we need to insert later
     habtm_fixtures = Hash.new do |h, habtm|
@@ -704,6 +708,9 @@
           end
 
         yaml_value.each do |fixture|
+          unless fixture.respond_to? :each
+            raise Fixture::FormatError, "Bad data type for #{@class_name} fixture"
+          end
           fixture.each do |name, data|
             unless data
               raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{name} (nil)"
@@ -716,7 +723,7 @@
     end
 
     def read_csv_fixture_files
-      reader = CSV::Reader.create(erb_render(IO.read(csv_file_path)))
+      reader = CSV.parse(erb_render(IO.read(csv_file_path)))
       header = reader.shift
       i = 0
       reader.each do |row|
Index: actionpack/test/controller/helper_test.rb
===================================================================
--- actionpack/test/controller/helper_test.rb	(revision 8514)
+++ actionpack/test/controller/helper_test.rb	(working copy)
@@ -91,7 +91,8 @@
     assert_nothing_raised {
       @controller_class.helper { def block_helper_method; end }
     }
-    assert master_helper_methods.include?('block_helper_method')
+    flunk 'Ruby 1.9.0 bug: Helpers don\'t work properly.' if RUBY_VERSION == '1.9.0'
+    assert master_helper_methods.map(&:to_sym).include?(:block_helper_method)
   end
 
   def test_helper_block_include
@@ -104,13 +105,13 @@
 
   def test_helper_method
     assert_nothing_raised { @controller_class.helper_method :delegate_method }
-    assert master_helper_methods.include?('delegate_method')
+    assert master_helper_methods.map(&:to_sym).include?(:delegate_method)
   end
 
   def test_helper_attr
     assert_nothing_raised { @controller_class.helper_attr :delegate_attr }
-    assert master_helper_methods.include?('delegate_attr')
-    assert master_helper_methods.include?('delegate_attr=')
+    assert master_helper_methods.map(&:to_sym).include?(:delegate_attr)
+    assert master_helper_methods.map(&:to_sym).include?(:delegate_attr=)
   end
 
   def test_helper_for_nested_controller
@@ -130,25 +131,25 @@
   end
 
   def test_all_helpers
-    methods = ApplicationController.master_helper_module.instance_methods.map(&:to_s)
+    methods = ApplicationController.master_helper_module.instance_methods.map(&:to_sym)
 
     # abc_helper.rb
-    assert methods.include?('bare_a')
+    assert methods.include?(:bare_a)
 
     # fun/games_helper.rb
-    assert methods.include?('stratego')
+    assert methods.include?(:stratego)
 
     # fun/pdf_helper.rb
-    assert methods.include?('foobar')
+    assert methods.include?(:foobar)
   end
 
   private
     def expected_helper_methods
-      TestHelper.instance_methods.map(&:to_s)
+      TestHelper.instance_methods.map(&:to_sym)
     end
 
     def master_helper_methods
-      @controller_class.master_helper_module.instance_methods.map(&:to_s)
+      @controller_class.master_helper_module.instance_methods.map(&:to_sym)
     end
 
     def missing_methods
@@ -197,10 +198,12 @@
   end
 
   def test_helper_in_b
+    flunk 'Ruby 1.9.0 bug: Helpers don\'t work properly.' if RUBY_VERSION == '1.9.0'
     assert_equal 'B', B.process(@request, @response).body
   end
 
   def test_helper_in_c
+    flunk 'Ruby 1.9.0 bug: Helpers don\'t work properly.' if RUBY_VERSION == '1.9.0'
     assert_equal 'C', C.process(@request, @response).body
   end
 end
Index: actionpack/test/controller/routing_test.rb
===================================================================
--- actionpack/test/controller/routing_test.rb	(revision 8514)
+++ actionpack/test/controller/routing_test.rb	(working copy)
@@ -31,8 +31,8 @@
     safe, unsafe = %w(: @ & = + $ , ;), %w(^ / ? # [ ])
     hex = unsafe.map { |char| '%' + char.unpack('H2').first.upcase }
 
-    @segment = "#{safe}#{unsafe}".freeze
-    @escaped = "#{safe}#{hex}".freeze
+    @segment = "#{safe.join}#{unsafe.join}".freeze
+    @escaped = "#{safe.join}#{hex.join}".freeze
   end
 
   def test_route_generation_escapes_unsafe_path_characters
Index: actionpack/test/controller/new_render_test.rb
===================================================================
--- actionpack/test/controller/new_render_test.rb	(revision 8514)
+++ actionpack/test/controller/new_render_test.rb	(working copy)
@@ -518,6 +518,7 @@
 
   def test_enum_rjs_test
     get :enum_rjs_test
+    flunk 'Ruby 1.9.0 bug: Helper methods don\'t work properly.' if RUBY_VERSION == '1.9.0'
     assert_equal <<-EOS.strip, @response.body
 $$(".product").each(function(value, index) {
 new Effect.Highlight(element,{});
Index: actionpack/test/controller/html-scanner/sanitizer_test.rb
===================================================================
--- actionpack/test/controller/html-scanner/sanitizer_test.rb	(revision 8514)
+++ actionpack/test/controller/html-scanner/sanitizer_test.rb	(working copy)
@@ -47,10 +47,13 @@
     assert_sanitized "a b c<script language=\"Javascript\">blah blah blah</script>d e f", "a b cd e f"
   end
 
-  # fucked
   def test_sanitize_js_handlers
     raw = %{onthis="do that" <a href="#" onclick="hello" name="foo" onbogus="remove me">hello</a>}
-    assert_sanitized raw, %{onthis="do that" <a name="foo" href="#">hello</a>}
+    if RUBY_VERSION >= '1.9'  # ordered Hash
+      assert_sanitized raw, %{onthis="do that" <a href="#" name="foo">hello</a>}
+    else
+      assert_sanitized raw, %{onthis="do that" <a name="foo" href="#">hello</a>}
+    end
   end
 
   def test_sanitize_javascript_href
Index: actionpack/test/controller/assert_select_test.rb
===================================================================
--- actionpack/test/controller/assert_select_test.rb	(revision 8514)
+++ actionpack/test/controller/assert_select_test.rb	(working copy)
@@ -347,8 +347,8 @@
     assert_select_rjs do
       assert_select "#1", :text => "\343\203\201\343\202\261\343\203\203\343\203\210"
       assert_select "#1", "\343\203\201\343\202\261\343\203\203\343\203\210"
-      assert_select "#1", Regexp.new("\343\203\201..\343\203\210",0,'U')
-      assert_raises(AssertionFailedError) { assert_select "#1", Regexp.new("\343\203\201.\343\203\210",0,'U') }
+      assert_select "#1", /\343\203\201..\343\203\210/u
+      assert_raises(AssertionFailedError) { assert_select "#1", /\343\203\201.\343\203\210/u }
     end
   end
 
Index: actionpack/test/controller/components_test.rb
===================================================================
--- actionpack/test/controller/components_test.rb	(revision 8514)
+++ actionpack/test/controller/components_test.rb	(working copy)
@@ -69,6 +69,14 @@
   def rescue_action(e) raise end
 end
 
+if RUBY_VERSION == '1.9.0'
+  class ComponentsTest < Test::Unit::TestCase
+    def test_warn
+      flunk 'Ruby 1.9.0 bug: Components don\'t work.' if RUBY_VERSION == '1.9.0'
+    end
+  end
+else
+
 class ComponentsTest < Test::Unit::TestCase
   def setup
     @controller = CallerController.new
@@ -138,3 +146,5 @@
       %("#{Digest::MD5.hexdigest(text)}")
     end
 end
+
+end
\ No newline at end of file
Index: actionpack/test/controller/filters_test.rb
===================================================================
--- actionpack/test/controller/filters_test.rb	(revision 8514)
+++ actionpack/test/controller/filters_test.rb	(working copy)
@@ -697,7 +697,7 @@
 end
 
 class ControllerWithWrongFilterType < PostsController
-  around_filter lambda { yield }, :only => :no_raise
+  around_filter lambda { |two, arguments| yield }, :only => :no_raise
 end
 
 class ControllerWithNestedFilters < ControllerWithSymbolAsFilter
Index: actionpack/test/template/form_options_helper_test.rb
===================================================================
--- actionpack/test/template/form_options_helper_test.rb	(revision 8514)
+++ actionpack/test/template/form_options_helper_test.rb	(working copy)
@@ -109,20 +109,38 @@
       )
   end
 
-  # FIXME: fails on Ruby 1.9, probably in html-scanner
-  def test_hash_options_for_select
-    assert_dom_equal(
-      "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
-      options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
-    )
-    assert_dom_equal(
-      "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
-      options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
-    )
-    assert_dom_equal(
-      "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
-      options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
-    )
+  if RUBY_VERSION >= '1.9'
+    # Depend on Hash preserving order.
+    def test_hash_options_for_select
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
+        options_for_select({ "<DKR>" => "<Kroner>", "$" => "Dollar" })
+      )
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+        options_for_select({ "<DKR>" => "<Kroner>", "$" => "Dollar" }, "Dollar")
+      )
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+        options_for_select({ "<DKR>" => "<Kroner>", "$" => "Dollar" }, [ "Dollar", "<Kroner>" ])
+      )
+    end
+  else
+    # Should pass for Ruby 1.8, although Hash ordering is undefined.
+    def test_hash_options_for_select
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
+        options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
+      )
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+        options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
+      )
+      assert_dom_equal(
+        "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+        options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
+      )
+    end
   end
 
   def test_ducktyped_options_for_select
Index: actionpack/Rakefile
===================================================================
--- actionpack/Rakefile	(revision 8514)
+++ actionpack/Rakefile	(working copy)
@@ -1,9 +1,10 @@
 require 'rubygems'
-require 'rake'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/packagetask'
 require 'rake/gempackagetask'
+
 require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
 
 PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
Index: actionpack/lib/action_controller/cgi_ext/cookie.rb
===================================================================
--- actionpack/lib/action_controller/cgi_ext/cookie.rb	(revision 8514)
+++ actionpack/lib/action_controller/cgi_ext/cookie.rb	(working copy)
@@ -37,7 +37,7 @@
         @path = nil
       else
         @name = name['name']
-        @value = Array(name['value'])
+        @value = name['value'].blank? ? [] : Array(name['value'])
         @domain = name['domain']
         @expires = name['expires']
         @secure = name['secure'] || false
Index: actionpack/lib/action_controller/assertions/selector_assertions.rb
===================================================================
--- actionpack/lib/action_controller/assertions/selector_assertions.rb	(revision 8514)
+++ actionpack/lib/action_controller/assertions/selector_assertions.rb	(working copy)
@@ -271,6 +271,7 @@
                 text << node.content
               end
             end
+            text.force_encoding(match_with.encoding) if match_with.respond_to?(:encoding)
             text.strip! unless NO_STRIP.include?(match.name)
             unless match_with.is_a?(Regexp) ? (text =~ match_with) : (text == match_with.to_s)
               content_mismatch ||= build_message(message, "<?> expected but was\n<?>.", match_with, text)
Index: actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
===================================================================
--- actionpack/lib/action_controller/vendor/html-scanner/html/node.rb	(revision 8514)
+++ actionpack/lib/action_controller/vendor/html-scanner/html/node.rb	(working copy)
@@ -134,7 +134,7 @@
       equivalent
     end
     
-    class <<self
+    class << self
       def parse(parent, line, pos, content, strict=true)
         if content !~ /^<\S/
           Text.new(parent, line, pos, content)
Index: actionpack/lib/action_view/helpers/text_helper.rb
===================================================================
--- actionpack/lib/action_view/helpers/text_helper.rb	(revision 8514)
+++ actionpack/lib/action_view/helpers/text_helper.rb	(working copy)
@@ -47,8 +47,8 @@
       #   # => And they found... (continued)
       def truncate(text, length = 30, truncate_string = "...")
         if text.nil? then return end
-        l = length - truncate_string.chars.length
-        (text.chars.length > length ? text.chars[0...l] + truncate_string : text).to_s
+        l = length - truncate_string.unicode_safe.length
+        (text.unicode_safe.length > length ? text.unicode_safe[0...l] + truncate_string : text).to_s
       end
 
       # Highlights one or more +phrases+ everywhere in +text+ by inserting it into
@@ -102,14 +102,14 @@
         if text.nil? || phrase.nil? then return end
         phrase = Regexp.escape(phrase)
 
-        if found_pos = text.chars =~ /(#{phrase})/i
+        if found_pos = text.unicode_safe =~ /(#{phrase})/i
           start_pos = [ found_pos - radius, 0 ].max
-          end_pos   = [ found_pos + phrase.chars.length + radius, text.chars.length ].min
+          end_pos   = [ found_pos + phrase.unicode_safe.length + radius, text.unicode_safe.length ].min
 
           prefix  = start_pos > 0 ? excerpt_string : ""
-          postfix = end_pos < text.chars.length ? excerpt_string : ""
+          postfix = end_pos < text.unicode_safe.length ? excerpt_string : ""
 
-          prefix + text.chars[start_pos..end_pos].strip + postfix
+          prefix + text.unicode_safe[start_pos..end_pos].strip + postfix
         else
           nil
         end
Index: actionpack/lib/action_view/helpers/prototype_helper.rb
===================================================================
--- actionpack/lib/action_view/helpers/prototype_helper.rb	(revision 8514)
+++ actionpack/lib/action_view/helpers/prototype_helper.rb	(working copy)
@@ -1204,7 +1204,7 @@
         append_enumerable_function!("zip(#{arguments_for_call arguments}")
         if block
           function_chain[-1] += ", function(array) {"
-          yield ActiveSupport::JSON::Variable.new('array')
+          yield ::ActiveSupport::JSON::Variable.new('array')
           add_return_statement!
           @generator << '});'
         else
Index: actionpack/lib/action_view/base.rb
===================================================================
--- actionpack/lib/action_view/base.rb	(revision 8514)
+++ actionpack/lib/action_view/base.rb	(working copy)
@@ -296,7 +296,7 @@
           template_file_name = full_template_path(template_path_without_extension, template_extension)
         else
           template_extension = pick_template_extension(template_path).to_s
-          unless template_extension
+          if template_extension.blank?
             raise ActionViewError, "No template found for #{template_path} in #{view_paths.inspect}"
           end
           template_file_name = full_template_path(template_path, template_extension)
Index: railties/Rakefile
===================================================================
--- railties/Rakefile	(revision 8514)
+++ railties/Rakefile	(working copy)
@@ -1,4 +1,5 @@
-require 'rake'
+require 'rubygems'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 require 'rake/gempackagetask'
Index: railties/fresh_rakefile
===================================================================
--- railties/fresh_rakefile	(revision 8514)
+++ railties/fresh_rakefile	(working copy)
@@ -3,7 +3,7 @@
 
 require(File.join(File.dirname(__FILE__), 'config', 'boot'))
 
-require 'rake'
+gem 'rake'
 require 'rake/testtask'
 require 'rake/rdoctask'
 
