class Comment < ApplicationRecord
belongs_to :article
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 2_000 }
class CommentsController < ApplicationController
before_action :set_post
def create
@comment = @post.comments.build(comment_params)