diff --git a/core/lib/solidus_core.rb b/core/lib/solidus_core.rb index 91268429010..3b69d6d6664 100644 --- a/core/lib/solidus_core.rb +++ b/core/lib/solidus_core.rb @@ -1,20 +1,3 @@ # frozen_string_literal: true require 'spree_core' - -class Arel::Table - def table_name - name - end -end - - -module RansackNodeConditionPatch - private - - def casted_array?(predicate) - predicate.is_a?(Arel::Nodes::Casted) && predicate.value.is_a?(Array) - end - - Ransack::Nodes::Condition.prepend(self) -end diff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rb index 54d4f60987f..afe782eceef 100644 --- a/core/lib/spree/core.rb +++ b/core/lib/spree/core.rb @@ -19,8 +19,11 @@ require 'monetize' require 'paperclip' require 'ransack' +require 'state_machines-activemodel' require 'state_machines-activerecord' +require_relative './ransack-4-1-patch' + # This is required because ActiveModel::Validations#invalid? conflicts with the # invalid state of a Payment. In the future this should be removed. StateMachines::Machine.ignore_method_conflicts = true diff --git a/core/lib/spree/ransack_4_1_patch.rb b/core/lib/spree/ransack_4_1_patch.rb new file mode 100644 index 00000000000..f531de330d8 --- /dev/null +++ b/core/lib/spree/ransack_4_1_patch.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "ransack/version" + +return unless Ransack::VERSION.start_with?("4.1.") + +module RansackNodeConditionPatch + private + + # Waiting for https://github.com/activerecord-hackery/ransack/pull/1468 + def casted_array?(predicate) + predicate.is_a?(Arel::Nodes::Casted) && predicate.value.is_a?(Array) + end + + Ransack::Nodes::Condition.prepend(self) +end