josevalim/active_model_serializers — pull request #65 by teeparham (2012-05-18 19:10:08+00:00)
Title: use :root option in render :json

Currently there is no way to serialize an array with no root.

With this commit, ArraySerializer can render arrays with no root, if `root: false` is specified:

`render json: [], root: false`

Somewhat related is issue #31, which asks to use the `ActiveRecord::Base.include_root_in_json` setting when rendering arrays. It seems tricky since that method could be overridden in individual models, and `_render_option_json` does not know the class of the model being rendered. So it seems like it a better solution would be an option in ArraySerializer itself. That would enable this to be a global setting & render calls in index methods would be more DRY. Either way we still need the option in this commit.