Hello, I’m able to create and send a JSON object like so:
@mylist << {
:id => item.id,
:name => name.id
}
render :json => { :result => 'success', :mylist => @mylist }
That works great. Problem I’m having now is that I need to include
users which can be 1 or users per item.
@mylist << {
:id => item.id,
:name => name.id,
:users => item.users
}
Where item.users
contains a list of (user.id, user.name, user.desc).
how do I include an array like users inside a json object? Right now
it is including all the user columns which I don’t need. How can I
specify which columns to include. Also it appears to be breaking the
JSON object, now everything following the first item.users in the JSON
object is:
,{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},
{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],“result”:“success”}
Thanks