<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2626,8 +2626,15 @@ module ActiveRecord #:nodoc:
         quoted = {}
         connection = self.class.connection
         attribute_names.each do |name|
-          if column = column_for_attribute(name)
-            quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key &amp;&amp; column.primary
+          if (column = column_for_attribute(name)) &amp;&amp; (include_primary_key || !column.primary)
+            value = read_attribute(name)
+
+            # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML.
+            if value &amp;&amp; self.class.serialized_attributes.has_key?(name) &amp;&amp; (value.acts_like?(:date) || value.acts_like?(:time))
+              value = value.to_yaml
+            end
+
+            quoted[name] = connection.quote(value, column)
           end
         end
         include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)</diff>
      <filename>activerecord/lib/active_record/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1361,6 +1361,12 @@ class BasicsTest &lt; ActiveRecord::TestCase
     assert_equal(myobj, topic.content)
   end
 
+  def test_serialized_time_attribute
+    myobj = Time.local(2008,1,1,1,0)
+    topic = Topic.create(&quot;content&quot; =&gt; myobj).reload
+    assert_equal(myobj, topic.content)
+  end
+
   def test_nil_serialized_attribute_with_class_constraint
     myobj = MyObject.new('value1', 'value2')
     topic = Topic.new</diff>
      <filename>activerecord/test/cases/base_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1b127fcdea28d6c6ab2f2c6370125c8817ba99d6</id>
    </parent>
  </parents>
  <author>
    <name>Tarmo T&#228;nav</name>
    <email>tarmo@itech.ee</email>
  </author>
  <url>http://github.com/rails/rails/commit/a5aad2e81febfa1a8d9fea0faffb5a3b4535982b</url>
  <id>a5aad2e81febfa1a8d9fea0faffb5a3b4535982b</id>
  <committed-date>2008-08-12T20:29:07-07:00</committed-date>
  <authored-date>2008-08-12T20:18:01-07:00</authored-date>
  <message>Fixed Time/Date object serialization

Time/Date objects used to be converted to_s instead of to_uaml
which made them unserializable.</message>
  <tree>f1936fe0655d0dd5fd0a6da1ac1e1d5d5b7d61e2</tree>
  <committer>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </committer>
</commit>
