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)
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 2_000 }
import { useLayoutEffect, useRef, useCallback } from 'react';
export function useScrollAnchor(anchorItemCount) {
const containerRef = useRef(null);
const savedRef = useRef(null);