Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:28:26+00:00 2026-06-07T15:28:26+00:00

I am using active_model_serializers to render a collection as JSON for ember-data consumption. All

  • 0

I am using active_model_serializers to render a collection as JSON for ember-data consumption.
All is ok when rendering a single item, but collection rendering consists as an array of items.

render json: @scenarios, status: :ok

gives:

[{"scenario":{"id":4,"name":"My sample scenario"}},{"scenario":{"id":5,"name":"Yet another sample scenario"}}]

but I would like to obtain:

{"scenarios": [{"id":4,"name":"My sample scenario"},{"id":5,"name":"Yet another sample scenario"}]}

What is the state of the art way to get a root key with all collection items, side-data, and so on? (the documentation is not that clear about this)

EDIT

The scenario serializer is currently as follow:

class ScenarioSerializer < ActiveModel::Serializer
  attributes :id, :name
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:28:28+00:00Added an answer on June 7, 2026 at 3:28 pm

    Try the latest version. AMS uses the controller name as the key for an array. By default it should render like you showed above.

    If your controller is not named ScenariosController, you can force the root element of the array like this:

    render json: @scenarios, root: "scenarios", status: :ok
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using active accessibility framework to enumerate all the controls for a given
I asked a previous question about serialization and validation. Someone mentioned using the JSON
Has anyone been able to get access to Active Directory using Entity Data Model?.
Hi all I'm using active_resource and have next question. sometimes there is destroy validation
I am making an MVC EditorTemplate for the bool data type that will render
I am using Active Record on CodeIgniter. I am confused on which approach I
I have a website which using active directory authorization on a windows server in
In WPF and SubSonic 2 using Active Record, I was able to bind to
I have a 3.0.7 app using active scaffold from github vhochstein/master. I am using
I’m trying to authenticate users onto a MVC3 application using Active Directory (without login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.