aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-06-12 01:03:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-06-16 08:04:16 +0900
commit10b81fb51acc600926613e9ea78125635950a1f0 (patch)
tree0c3877333d41686d8ffc04a72d4dd75c0cf45e57 /activemodel
parent7980b31bc6dd123a0635f470998362a602b66e25 (diff)
downloadrails-10b81fb51acc600926613e9ea78125635950a1f0.tar.gz
rails-10b81fb51acc600926613e9ea78125635950a1f0.tar.bz2
rails-10b81fb51acc600926613e9ea78125635950a1f0.zip
Fix `Type::Date#serialize` to return a date object correctly
Currently `Type::Date#serialize` does not cast a value to a date object. It should be cast to a date object for finding by date column correctly working. Fixes #25354.
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/type/date.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/type/date.rb b/activemodel/lib/active_model/type/date.rb
index f74243a22c..edd07ac38c 100644
--- a/activemodel/lib/active_model/type/date.rb
+++ b/activemodel/lib/active_model/type/date.rb
@@ -7,6 +7,10 @@ module ActiveModel
:date
end
+ def serialize(value)
+ cast(value)
+ end
+
def type_cast_for_schema(value)
"'#{value.to_s(:db)}'"
end