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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Support Rails 7.1 in Ransack
Rafal Cymerys217e261fca43
diff --git a/core/lib/ransack/context_decorator.rb b/core/lib/ransack/context_decorator.rbnew file mode 100644index 0000000000..51a2a0e34d--- /dev/null+++ b/core/lib/ransack/context_decorator.rb@@ -0,0 +1,25 @@+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.rbindex 370fdf4bad..7f98d35c16 100644--- a/core/lib/spree_core.rb+++ b/core/lib/spree_core.rb@@ -1,4 +1,7 @@require 'friendly_id/paranoia'require 'mobility/plugins/store_based_fallbacks'+if Rails::VERSION::STRING >= '7.1.0'+ require 'ransack/context_decorator'+endrequire 'spree/core'