Files
juxtapoandClaude Opus 5 a58a61b98c Pak Jabit: full stack — storefront, Spree customisations, catalogue tooling
A South African men's apparel store on Spree 5.6 + Next.js 15. 160 products
live, three markets, live Malaysian courier rates, customer-owned carts.

What is here:
  storefront/  the Next.js app
  backend/     ONLY the custom Spree code. Spree itself is a prebuilt image
               that mounts no app code, so every file here needs an explicit
               volume entry in docker-compose.yml or it is silently ignored.
  catalogue/   the scripts that loaded and maintain the products
  docs/        manifest, mock registry, napkins

Real .env files are committed deliberately. This lives on the house's private
Gitea, and a clone that runs beats a clone that needs a secrets handover.
LANDMINE.md maps every key, what it opens, and what must be rotated before this
repo goes anywhere less private.

The admin API key used to be a literal in six catalogue scripts. They now read
SPREE_ADMIN_KEY from the environment and refuse to run without it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 22:09:55 +08:00

34 lines
1.3 KiB
Ruby

# Customer address labels — "Home", "Office", "Mom's place".
#
# Spree::Address already HAS a `label` column, and the ADMIN serializer already
# exposes it. The STORE API does neither: AddressesController#permitted_params
# omits :label, so a POST carrying one answers 201 and saves nil — no error, no
# warning, the field just vanishes. Spree::Addresses::Create passes params
# straight to Address.new, so permitting it is enough to persist it.
#
# prepend, not class_eval: permitted_params is defined directly on that
# controller, so redefining it in place would send `super` past the original to
# ResourceController and silently drop every other permitted field.
#
# Bind-mounted — the prebuilt ghcr.io/spree/spree image mounts no app code, so
# this file needs its own entry in docker-compose.yml's web volumes block.
module PakJabit
module CustomerAddressLabel
def permitted_params
super.merge(params.permit(:label))
end
end
end
Rails.application.config.to_prepare do
unless Spree::Api::V3::Store::Customer::AddressesController.include?(PakJabit::CustomerAddressLabel)
Spree::Api::V3::Store::Customer::AddressesController.prepend(PakJabit::CustomerAddressLabel)
end
Spree::Api::V3::AddressSerializer.class_eval do
typelize label: [:string, nullable: true]
attributes :label
end
end