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.

workaround for mobility bug with first_or_initialize

nciemniakd59e7f96115e
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 953aa777f9..c7d494e0d2 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -124,7 +124,12 @@ module Spree
# this behaviour is very buggy and unpredictable
def self.default
Rails.cache.fetch('default_store') do
- where(default: true).first_or_initialize
+ # workaround for Mobility bug with first_or_initialize
+ if where(default: true).any?
+ where(default: true).first
+ else
+ new(default: true)
+ end
end
end