lib/jsonapi/resource.rb in jsonapi-resources-0.8.2 vs lib/jsonapi/resource.rb in jsonapi-resources-0.8.3
- old
+ new
@@ -415,11 +415,13 @@
subclass._allowed_filters = (_allowed_filters || Set.new).dup
type = subclass.name.demodulize.sub(/Resource$/, '').underscore
subclass._type = type.pluralize.to_sym
- subclass.attribute :id, format: :id
+ unless subclass._attributes[:id]
+ subclass.attribute :id, format: :id
+ end
check_reserved_resource_name(subclass._type, subclass.name)
end
def resource_for(type)
@@ -577,10 +579,10 @@
_updatable_relationships | _attributes.keys - [:id]
end
# Override in your resource to filter the creatable keys
def creatable_fields(_context = nil)
- _updatable_relationships | _attributes.keys
+ _updatable_relationships | _attributes.keys - [:id]
end
# Override in your resource to filter the sortable keys
def sortable_fields(_context = nil)
_attributes.keys