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:
João Moura
2015-08-28 07:47:55 -03:00
3 changed files with 65 additions and 1 deletions

View File

@@ -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 = {})

View File

@@ -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