From 34cc301f03aea2e579d6687a9ea9782afc1089a0 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 29 May 2018 04:58:26 +0900 Subject: Ensure casting by boolean attribute when querying `QueryAttribute#value_for_database` calls only `type.serialize`, and `Boolean#serialize` is a no-op unlike other attribute types. It caused the issue #32624. Whether or not `serialize` will invoke `cast` is undefined in our test cases, but it actually does not work properly unless it does so for now. Fixes #32624. --- activemodel/lib/active_model/type/boolean.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activemodel') diff --git a/activemodel/lib/active_model/type/boolean.rb b/activemodel/lib/active_model/type/boolean.rb index bcdbab0343..f6c6efbc87 100644 --- a/activemodel/lib/active_model/type/boolean.rb +++ b/activemodel/lib/active_model/type/boolean.rb @@ -20,6 +20,10 @@ module ActiveModel :boolean end + def serialize(value) # :nodoc: + cast(value) + end + private def cast_value(value) -- cgit v1.2.3