From 10b81fb51acc600926613e9ea78125635950a1f0 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 12 Jun 2016 01:03:10 +0900 Subject: 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. --- activemodel/lib/active_model/type/date.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activemodel/lib/active_model/type/date.rb') 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 -- cgit v1.2.3