Need help getting correct JSON output

The update function should return authorIds within the post map, however, I am unable to append to it. I am not sure how to do it since I have only been using it for about 2 days. Been stuck on this issue for while and would appreciate any help I can get. Thank you in advance.

It seems that authorIds is an association and not a column, and it’s not included in serialization by default. You can find something useful in the documentation below.

Thank you for replying, I appreciate it. However, I am not sure how this could help me append a key-value pair to the Post model. I am supposed to append authorIds into Post and return it. However, Post’s records does not have to be saved with authorIds. AuthorIds is only supposed to be returned in the JSON, nothing more.

you can do something like

post = current_user.posts.find_by(id: params[:id])
final_post = post.push(params[:authorIds]).as_json.merge(...)

Thank you, I understand the as_json method now. I appreciate it!