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.

This commit is contained in:
Todd Eichel 2013-06-20 00:55:29 -07:00
parent 77e3b26251
commit 5f3f4d5904

View file

@ -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