def create
@post=Post.find(params[:post_id])
@comment = @post.comments.new(comment_params.merge(user_id: current_user.id))
if @comment.save
redirect_to post_path(@post)
else
render : edit
end
end
class Comment < ApplicationRecord
mount_uploader :image, ImageUploader
validates:username, presence:true, length:{minimum:5}
validates:body, presence:true, length:{minimum:5}
belongs_to :user
belongs_to :post
end