mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Merge pull request #1081 from beauby/jsonapi-singular-plural-config
Add configuration option to set resource type to singular/plural
This commit is contained in:
@@ -151,7 +151,11 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def json_api_type
|
||||
object.class.model_name.plural
|
||||
if config.jsonapi_resource_type == :plural
|
||||
object.class.model_name.plural
|
||||
else
|
||||
object.class.model_name.singular
|
||||
end
|
||||
end
|
||||
|
||||
def attributes(options = {})
|
||||
|
||||
@@ -7,6 +7,7 @@ module ActiveModel
|
||||
included do |base|
|
||||
base.config.array_serializer = ActiveModel::Serializer::ArraySerializer
|
||||
base.config.adapter = :flatten_json
|
||||
base.config.jsonapi_resource_type = :plural
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user