mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Make sure render json: ..., each_serializer: ... is working with Enumerables
If you try to render Enumerable with custom `each_serializer` then it will render with default serializer instead: ```ruby render json: sequel_scope, each_serializer: CustomSerializer ``` This commit fixes this behaviour. Most likely fixes https://github.com/rails-api/active_model_serializers/issues/664 as well
This commit is contained in:
@@ -84,7 +84,7 @@ module ActionController
|
||||
if serializer = options.fetch(:serializer, default_serializer(resource))
|
||||
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
||||
|
||||
if resource.respond_to?(:to_ary)
|
||||
if resource.respond_to?(:each)
|
||||
options[:resource_name] = controller_name
|
||||
options[:namespace] = namespace_for_serializer if namespace_for_serializer
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user