mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #1418 from brigade/collection-pluralize
Don't pluralize the CollectionSerializer#root for #json_key
This commit is contained in:
@@ -23,8 +23,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def json_key
|
||||
key = root || serializers.first.try(:json_key) || object.try(:name).try(:underscore)
|
||||
key.try(:pluralize)
|
||||
root || derived_root
|
||||
end
|
||||
|
||||
def paginated?
|
||||
@@ -36,6 +35,13 @@ module ActiveModel
|
||||
protected
|
||||
|
||||
attr_reader :serializers
|
||||
|
||||
private
|
||||
|
||||
def derived_root
|
||||
key = serializers.first.try(:json_key) || object.try(:name).try(:underscore)
|
||||
key.try(:pluralize)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user