Add configuration option to set resource type to singular/plural with jsonapi.

This commit is contained in:
Lucas Hosseini
2015-08-24 22:46:11 +02:00
parent 87c47f8fdc
commit 91235ba7bc
3 changed files with 65 additions and 1 deletions

View File

@@ -135,7 +135,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