Allow JSONAPI unsuffixed associations keys

As shown here :
https://github.com/json-api/json-api/blob/gh-pages/format/index.md#resource-relationships-
This commit is contained in:
Gauthier Delacroix 2014-09-05 18:46:08 +02:00
parent 605408005f
commit 6f4f30cda6
2 changed files with 9 additions and 2 deletions

View File

@ -5,7 +5,11 @@ module ActiveModel
def initialize(name, *args)
super
@root_key = @embedded_key
@key ||= "#{name.to_s.singularize}_ids"
@key ||= case CONFIG.default_key_type
when :name then name.to_s.pluralize
else "#{name.to_s.singularize}_ids"
end
end
def serializer_class(object, _)

View File

@ -5,7 +5,10 @@ module ActiveModel
def initialize(name, *args)
super
@root_key = @embedded_key.to_s.pluralize
@key ||= "#{name}_id"
@key ||= case CONFIG.default_key_type
when :name then name.to_s.singularize
else "#{name}_id"
end
end
def serializer_class(object, options = {})