I am building a rails application to work as a back end for APIs. (using grape APIs) I have two tables (user, comment) where a user has many comments and a comment belongs to one users.
I am trying to return all comments, and within the Comment object, i want to show the User object for the user who created that comment.
I tried:
Comment.includes(:user)
and
Comment.joins(:user).includes(:user)
And none of them managed to return the sub-object. only returns the Comment object (which has user_id) attribute).
Is there any way to achieve that in a JSON format (as mentioned, I use GRAPE)