In a controller, the current controller name should be the default root for collections

This commit is contained in:
Yehuda Katz
2012-01-01 16:01:59 -08:00
parent e23553be23
commit 87d2d77ac8
2 changed files with 19 additions and 1 deletions

View File

@@ -37,6 +37,10 @@ module ActionController
end
def _render_option_json(json, options)
if json.is_a?(Array)
options[:root] ||= controller_name
end
if json.respond_to?(:active_model_serializer) && (serializer = json.active_model_serializer)
json = serializer.new(json, serialization_scope, options)
end