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.

Fixed `Base#json_api_permitted_attributes` for models using `acts_as_nested_set`

Damian Legawiec23222639e54a
diff --git a/core/app/models/spree/base.rb b/core/app/models/spree/base.rb
index f574311dde..48e8ded9c0 100644
--- a/core/app/models/spree/base.rb
+++ b/core/app/models/spree/base.rb
@@ -50,7 +50,13 @@ class Spree::Base < ApplicationRecord
end
def self.json_api_permitted_attributes
- column_names.reject { |c| c == 'id' }
+ skipped_attributes = %w[id]
+
+ if included_modules.include?(CollectiveIdea::Acts::NestedSet::Model)
+ skipped_attributes.push('lft', 'rgt', 'depth')
+ end
+
+ column_names.reject { |c| skipped_attributes.include?(c.to_s) }
end
def self.json_api_type