diff --git a/app/controllers/api/comments_controller.rb b/app/controllers/api/comments_controller.rb index 8d1982b..63a13b7 100644 --- a/app/controllers/api/comments_controller.rb +++ b/app/controllers/api/comments_controller.rb @@ -13,7 +13,7 @@ def create post = Post.find(params[:post_id]) comment = post.comments.build(comment_params) comment.user = current_user - + if comment.save render json: comment, status: :created else diff --git a/app/controllers/api/posts_controller.rb b/app/controllers/api/posts_controller.rb index 8f44c3c..29d43a8 100644 --- a/app/controllers/api/posts_controller.rb +++ b/app/controllers/api/posts_controller.rb @@ -2,7 +2,7 @@ class Api::PostsController < ApplicationController def index user = User.find(params[:user_id]) posts = user.posts - + if posts.present? render json: { message: 'Posts loaded successfully', data: posts }, status: :ok else