# 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