lib/jsonapi/resource.rb in jsonapi-resources-0.9.0.beta2 vs lib/jsonapi/resource.rb in jsonapi-resources-0.9.0.beta3
- old
+ new
@@ -428,11 +428,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 rebuild_relationships(relationships)
@@ -596,10 +598,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