Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Upgrade ransack and remove momkey patch

Rafal Cymerysb19e4f7912bf
diff --git a/core/lib/ransack/context_decorator.rb b/core/lib/ransack/context_decorator.rb
deleted file mode 100644
index 51a2a0e34d..0000000000
--- a/core/lib/ransack/context_decorator.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'ransack'
-
-module Ransack
- module Adapters
- module ActiveRecord
- module ContextDecorator
- def type_for(attr)
- return nil unless attr && attr.valid?
- name = attr.arel_attribute.name.to_s
- # Patched
- # Original implementation
- # table = attr.arel_attribute.relation.table_name
- table = attr.arel_attribute.relation.name
- schema_cache = self.klass.connection.schema_cache
- unless schema_cache.send(:data_source_exists?, table)
- raise "No table named #{table} exists."
- end
- attr.klass.columns.find { |column| column.name == name }.type
- end
- end
- end
- end
-end
-
-Ransack::Adapters::ActiveRecord::Context.prepend(Ransack::Adapters::ActiveRecord::ContextDecorator)
diff --git a/core/lib/spree_core.rb b/core/lib/spree_core.rb
index 7f98d35c16..370fdf4bad 100644
--- a/core/lib/spree_core.rb
+++ b/core/lib/spree_core.rb
@@ -1,7 +1,4 @@
require 'friendly_id/paranoia'
require 'mobility/plugins/store_based_fallbacks'
-if Rails::VERSION::STRING >= '7.1.0'
- require 'ransack/context_decorator'
-end
require 'spree/core'
diff --git a/core/spree_core.gemspec b/core/spree_core.gemspec
index f34e6958d2..a85ac7b143 100644
--- a/core/spree_core.gemspec
+++ b/core/spree_core.gemspec
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
s.add_dependency 'money', '~> 6.13'
s.add_dependency 'monetize', '~> 1.9'
s.add_dependency 'paranoia', '~> 2.4'
- s.add_dependency 'ransack', '>= 3.1', '< 4.0'
+ s.add_dependency 'ransack', '>= 4.1'
s.add_dependency 'rexml'
s.add_dependency 'state_machines-activerecord', '~> 0.6'
s.add_dependency 'state_machines-activemodel', '~> 0.7'