커뮤니티 댓글 — CommunityCommentsController + 중첩 댓글 + 좋아요 토글 + Turbo Stream + 테스트
ID: f9d82986-d489-40f5-b6b7-211a0a9dfcbd
## 목표
CommunityComments CRUD (중첩 댓글 parent_id). 좋아요 토글. Turbo Stream 실시간 갱신.
## 현재 상태
- CommunityCommentsController 스텁 (create, destroy)
- 라우트: `resources :community_posts do resources :community_comments, only: [:create, :destroy]; post :like, on: :member end`
- CommunityComment 모델: belongs_to :community_post, :user, :parent(optional, self-ref). has_many :replies. validates :content. likes_count
- CommunityPost#show에 댓글 placeholder 있음
## 구현 사항
### 1. CommunityCommentsController
- create: 댓글 생성 (parent_id로 대댓글 지원). Turbo Stream 응답
- destroy: 소유자만 삭제. Turbo Stream 응답
- strong params: content, parent_id
### 2. 게시글 show 페이지에 댓글 영역 추가
- community_posts/show에 댓글 목록 + 댓글 작성 폼
- 대댓글: parent_id가 있으면 들여쓰기
- 각 댓글: 내용, 작성자, 시간, 삭제(소유자), 답글 버튼
- Turbo Frame으로 각 댓글 감싸기
### 3. Turbo Stream
- 댓글 생성 시: Turbo Stream으로 목록에 추가 (prepend/append)
- 댓글 삭제 시: Turbo Stream으로 제거
### 4. 좋아요 토글 (게시글)
- CommunityPostsController#like 이미 구현됨 — 확인 후 필요시 개선
- 토글 방식: 한 번 누르면 +1, 다시 누르면 -1 (간단 구현 또는 현재 상태 유지)
### 5. comments_count 카운터
- 댓글 생성/삭제 시 community_post.comments_count 업데이트 (콜백 또는 counter_cache)
### ⚠️ 주의
- community_comments/ + community_posts/show 범위만 (developer-2는 cohorts/ 작업 중)
- 1depth 대댓글만 (parent → replies, replies에는 답글 불가)
- 다크 테마, 한국어
### 테스트
- create (댓글 + 대댓글), destroy (소유자만), Turbo Stream 응답
- comments_count 업데이트
### 완료 기준
- 댓글 작성/삭제, 대댓글 1depth, Turbo Stream 갱신
- bin/rails test 전체 통과
첨부 이미지
이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)
JPEG, PNG, GIF, WebP / 최대 10MB
활동 로그
-
Ddeveloper-1 상태 변경: 할 일 → 리뷰
2026년 03월 26일 12:19:11