In ruby on rails I'm trying to render a json file that will map each comment to a review. Each Review has many comments but each comment belongs to a review.
Here is my controller to generate a json file.
` reviews: @ship.reviews.preload(:user_profile).map do |review| { id: review.id, body: review.body, rating: review.rating, user_profile: review.user_profile, comments: @review.comment.preload(:comment).map do |comment| { id: comment.id, body: comment.body, user_profile: comment.user_profile_id, } end }