From 5f3f4d59046000fa97ba2ba854cee0acf71135bc Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 20 Jun 2013 00:55:29 -0700 Subject: [PATCH] Use the same test for resource array-ness that ActiveModel::Serializers itself uses. This should be more reliable and it's probably good to conform to AM::Serializers behavior wherever possible. --- lib/grape-active_model_serializers/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grape-active_model_serializers/formatter.rb b/lib/grape-active_model_serializers/formatter.rb index c0d8dae..4711860 100644 --- a/lib/grape-active_model_serializers/formatter.rb +++ b/lib/grape-active_model_serializers/formatter.rb @@ -13,7 +13,7 @@ module Grape @endpoint = env["api.endpoint"] options = endpoint.namespace_options.merge(endpoint.route_options) - if resource.is_a?(Array) && !resource.empty? + if resource.respond_to?(:to_ary) && !resource.empty? # ensure we have an root to fallback on endpoint.controller_name = resource.first.class.name.underscore.pluralize end