From e72e954aca2e402b456ae00bea0412504e393c60 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Fri, 15 Dec 2023 13:21:50 +0100 Subject: [PATCH] Check type before sending `#value` message to predicate The previous implementation was giving for granted that every predicate respond to `#value`, but that doesn't seem to be the case at least when having a `Arel::SelectManager`. by simply inverting the terms of the existing AND check we can fix the issue without introducing unknown side effects. --- lib/ransack/nodes/condition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ransack/nodes/condition.rb b/lib/ransack/nodes/condition.rb index af69c037..248638d2 100644 --- a/lib/ransack/nodes/condition.rb +++ b/lib/ransack/nodes/condition.rb @@ -339,7 +339,7 @@ def in_predicate?(predicate) end def casted_array?(predicate) - predicate.value.is_a?(Array) && predicate.is_a?(Arel::Nodes::Casted) + predicate.is_a?(Arel::Nodes::Casted) && predicate.value.is_a?(Array) end def format_values_for(predicate)