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.

Fix Carmen deprecation warning for Rails 8.2 compatibility (#13917)

Damian Legawiece7e8da870a86
diff --git a/spree/core/config/initializers/carmen.rb b/spree/core/config/initializers/carmen.rb
new file mode 100644
index 0000000000..b048408853
--- /dev/null
+++ b/spree/core/config/initializers/carmen.rb
@@ -0,0 +1,23 @@
+# Patches Carmen::Querying#normalise_name to avoid the deprecated
+# ActiveSupport::Multibyte::Chars API (mb_chars), which will be removed in
+# Rails 8.2.
+#
+# In Ruby 2.4+, String#downcase is already Unicode-aware, making the mb_chars
+# call redundant. Since Spree requires Ruby >= 3.2, we can drop it safely.
+#
+# This patch can be removed once the upstream gem is fixed.
+#
+# See: https://github.com/carmen-ruby/carmen/issues/304
+require 'carmen'
+
+module Spree
+ module CarmenQueryingPatch
+ private
+
+ def normalise_name(name)
+ name.downcase.unicode_normalize(:nfkc)
+ end
+ end
+end
+
+Carmen::Querying.prepend(Spree::CarmenQueryingPatch)