My Json output is not coming the way as expected by Ember. I am getting the following output:
{
"user":{
"id":3,
"email":"user5@user.com"
"username":"user5"
},
"uploads":[{
"id":5,
"user_id":3,
"image_file_name":"image-2.jpg"
},
{
"id":6,
"user_id":3,
"image_file_name":"image-4.jpg"
}]
}
What I am missing is in the user section of the json output is the upload_ids: [upload ids separated with commas] like this:
"user":{
"id":3,
"email":"user5@user.com"
"username":"user5",
"upload_ids":[5,6]
},
I have the following in the UserSerializer file:
attributes :id, :email, :username
has_many :uploads, embed: :ids, key: "uploads", include: true
In the users_controller.rb I have the following:
@uploads = @user.uploads.all
respond_with(:user=>@user, :uploads=>@uploads)
I have active model serializer gem version 0.9.2.
Please if someone can help with this, it will be hugely appreciated.
Aucun commentaire:
Enregistrer un commentaire