aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-12-11 12:35:30 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2012-12-11 12:35:30 +0000
commit4dd563592208a1d1a5d617ceaa8c22aa8a56adb8 (patch)
tree5d34fa0ffbbdd07f76c73b4e1df0b7091886246a
parentf0a9e2f8520240dea3c23c4b971fb45d1c83eeaa (diff)
downloadrails-4dd563592208a1d1a5d617ceaa8c22aa8a56adb8.tar.gz
rails-4dd563592208a1d1a5d617ceaa8c22aa8a56adb8.tar.bz2
rails-4dd563592208a1d1a5d617ceaa8c22aa8a56adb8.zip
Only call `in_time_zone` on Time or DateTime instances
Both String and Date now respond to in_time_zone so we need to check if the value is a Time or a DateTime.
-rwxr-xr-xactivemodel/lib/active_model/serializers/xml.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb
index 4a17a63e20..648ae7ce3d 100755
--- a/activemodel/lib/active_model/serializers/xml.rb
+++ b/activemodel/lib/active_model/serializers/xml.rb
@@ -2,6 +2,7 @@ require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/hash/conversions'
require 'active_support/core_ext/hash/slice'
+require 'active_support/core_ext/time/acts_like'
module ActiveModel
module Serializers
@@ -20,7 +21,11 @@ module ActiveModel
def initialize(name, serializable, value)
@name, @serializable = name, serializable
- value = value.in_time_zone if value.respond_to?(:in_time_zone)
+
+ if value.acts_like?(:time) && value.respond_to?(:in_time_zone)
+ value = value.in_time_zone
+ end
+
@value = value
@type = compute_type
end