I have a rails api with the "active_model_serializers" gem.
http://localhost:3000/api/buildings/30.json generates for me this:
{
building:{
id:30,
city_name:"msc",
infrastructure:[
{
id:40,
name:"name 1",
created_at:"2015-07-30T08:26:49.000Z",
updated_at:"2015-07-30T08:26:49.000Z"
},
{
id:69,
name:"name 2",
created_at:"2015-07-30T08:26:50.000Z",
updated_at:"2015-07-30T08:26:50.000Z"
},
{
id:39,
name:"name 3",
created_at:"2015-07-30T08:26:49.000Z",
updated_at:"2015-07-30T08:26:49.000Z"
}
]
}
}
Also I use EmberJs with ActiveModelAdapter. But Ember expects this:
{
building:{
id:30,
city_name:"msc",
infrastructure:[
40,
69,
39
]
},
infrastructure:[
{
id:40,
name:"name 1",
created_at:"2015-07-30T08:26:49.000Z",
updated_at:"2015-07-30T08:26:49.000Z"
},
{
id:69,
name:"name 2",
created_at:"2015-07-30T08:26:50.000Z",
updated_at:"2015-07-30T08:26:50.000Z"
},
{
id:39,
name:"name 3",
created_at:"2015-07-30T08:26:49.000Z",
updated_at:"2015-07-30T08:26:49.000Z"
}
]
}
How can I make ember working with rails json structure? Thx!