mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
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:
@@ -5,7 +5,11 @@ module ActiveModel
|
|||||||
def initialize(name, *args)
|
def initialize(name, *args)
|
||||||
super
|
super
|
||||||
@root_key = @embedded_key
|
@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
|
end
|
||||||
|
|
||||||
def serializer_class(object, _)
|
def serializer_class(object, _)
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ module ActiveModel
|
|||||||
def initialize(name, *args)
|
def initialize(name, *args)
|
||||||
super
|
super
|
||||||
@root_key = @embedded_key.to_s.pluralize
|
@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
|
end
|
||||||
|
|
||||||
def serializer_class(object, options = {})
|
def serializer_class(object, options = {})
|
||||||
|
|||||||
Reference in New Issue
Block a user