File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -430,7 +430,9 @@ def inherited(subclass)
430430 type = subclass . name . demodulize . sub ( /Resource$/ , '' ) . underscore
431431 subclass . _type = type . pluralize . to_sym
432432
433- subclass . attribute :id , format : :id
433+ unless subclass . _attributes [ :id ]
434+ subclass . attribute :id , format : :id
435+ end
434436
435437 check_reserved_resource_name ( subclass . _type , subclass . name )
436438 end
@@ -598,7 +600,7 @@ def updatable_fields(_context = nil)
598600
599601 # Override in your resource to filter the creatable keys
600602 def creatable_fields ( _context = nil )
601- _updatable_relationships | _attributes . keys
603+ _updatable_relationships | _attributes . keys - [ :id ]
602604 end
603605
604606 # Override in your resource to filter the sortable keys
Original file line number Diff line number Diff line change @@ -1120,7 +1120,7 @@ def self.updatable_fields(context)
11201120 end
11211121
11221122 def self . creatable_fields ( context )
1123- super ( context ) - [ :subject , :id ]
1123+ super ( context ) - [ :subject ]
11241124 end
11251125
11261126 def self . sortable_fields ( context )
@@ -1142,6 +1142,10 @@ class HairCutResource < JSONAPI::Resource
11421142class IsoCurrencyResource < JSONAPI ::Resource
11431143 attributes :name , :country_name , :minor_unit
11441144
1145+ def self . creatable_fields ( _context = nil )
1146+ super + [ :id ]
1147+ end
1148+
11451149 filter :country_name
11461150
11471151 key_type :string
You can’t perform that action at this time.
0 commit comments