@spree/docs 0.1.173 → 0.1.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -353,11 +353,30 @@ A store or channel still carrying `preferred_order_routing_strategy: 'Spree::Ord
353
353
 
354
354
  `Spree::Stock::Coordinator` itself stays — cart fulfillment building, exchanges, and claims still use it.
355
355
 
356
+ ### `belongs_to` is required by default
357
+
358
+ Spree models followed Rails' pre-5 rule, where a `belongs_to` was optional
359
+ unless you said otherwise. They now follow the modern default: a `belongs_to`
360
+ is **required** unless it is declared `optional: true`.
361
+
362
+ Two consequences for an application built on Spree:
363
+
364
+ - **Your own models change with it.** Anything inheriting from `Spree::Base`
365
+ picks up the new default, so an association that is legitimately blank now
366
+ needs `optional: true` on it. A model that relied on the old behaviour will
367
+ start failing validation until you say which associations are optional.
368
+ - **The message changed.** A missing association reports `"must exist"` rather
369
+ than `"can't be blank"`. Code that matches on the old wording — a test, or a
370
+ client reading `details` out of a 422 — needs updating.
371
+
372
+ Setting a record's association to `nil` and saving it is the quickest way to
373
+ tell whether an association is required.
374
+
356
375
  ### `Store.default` no longer builds a store
357
376
 
358
377
  `Spree::Store.default` returned an **unpersisted** `Store.new(default: true)` when no default store existed. It now returns `nil`.
359
378
 
360
- This matters more than it looks: `Spree::Current.store` falls back to `Store.default`, and every `Spree::SingleStoreResource` model resolves its own `store` from `Spree::Current.store`. Without a default store, those records now fail validation with "Store can't be blank" instead of silently attaching to a throwaway store.
379
+ This matters more than it looks: `Spree::Current.store` falls back to `Store.default`, and every `Spree::SingleStoreResource` model resolves its own `store` from `Spree::Current.store`. Without a default store, those records now fail validation with "Store must exist" instead of silently attaching to a throwaway store.
361
380
 
362
381
  Make sure a default store exists before creating store-scoped records, and set `Spree::Current.store` in jobs, rake tasks, and tests that run outside a request.
363
382
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.173",
3
+ "version": "0.1.175",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",