mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Fail if collection type cannot be inferred with json adapter (#2210)
This commit is contained in:
@@ -46,7 +46,10 @@ module ActiveModel
|
||||
# 3. get from collection name, if a named collection
|
||||
key ||= object.respond_to?(:name) ? object.name && object.name.underscore : nil
|
||||
# 4. key may be nil for empty collection and no serializer option
|
||||
key && key.pluralize
|
||||
key &&= key.pluralize
|
||||
# 5. fail if the key cannot be determined
|
||||
key || fail(ArgumentError, 'Cannot infer root key from collection type. Please
|
||||
specify the root or each_serializer option, or render a JSON String')
|
||||
end
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user