QT 메인 페이지 + 묵상 기록 CRUD
ID: cbdf9ccb-f305-4615-84ac-8fd1f7016c42
## 목표
QT 메인 페이지(오늘의 QT)와 묵상 기록 저장/조회 기능을 구현합니다.
## 작업 범위
### 1. UserMeditation 모델 + 마이그레이션
```ruby
create_table :user_meditations, id: :uuid do |t|
t.references :user, type: :uuid, null: false, foreign_key: true
t.references :qt_content, type: :uuid, null: false, foreign_key: true
t.date :meditation_date, null: false
t.text :personal_meditation
t.text :action_plan
t.text :prayer_topic
t.integer :mood_before # 1-5
t.integer :mood_after # 1-5
t.integer :completion_minutes
t.boolean :is_tongtok_completed, default: false
t.boolean :is_personal_meditation_shared, default: false
t.boolean :is_action_plan_shared, default: false
t.boolean :is_prayer_topic_shared, default: false
t.json :highlights
t.integer :bible_chapter
t.integer :bible_verse
t.timestamps
end
add_index :user_meditations, [:user_id, :qt_content_id], unique: true
```
- User has_many :user_meditations
- QtContent has_many :user_meditations
### 2. QtController
- `today` 액션: 현재 세션 기준 오늘의 QT 콘텐츠 조회
- current_user.current_session_id 또는 user_setting.current_session_id로 세션 찾기
- 세션의 start_date와 오늘 날짜 차이로 day_number 계산
- 해당 day_number의 qt_content 조회
- 기존 묵상 기록이 있으면 함께 로드
- `day` 액션: params[:day]로 특정 일차 QT 조회
### 3. MeditationsController
- `create`: 묵상 기록 생성 (Turbo Stream 응답)
- `update`: 기존 묵상 수정 (Turbo Stream 응답)
- 자동 저장: Stimulus debounce + Turbo Stream
### 4. QT 뷰
- app/views/qt/today.html.erb: QT 메인 페이지
- 성경 구절 표시 (bible_passage)
- 테마 제목 (theme_title)
- 본문 내용 (content)
- 질문 5개 표시 (questions JSON array)
- 일차 네비게이션 (이전/다음 버튼)
- 묵상 기록 폼 (Turbo Frame)
- 세션 미참여 시 안내 메시지
- app/views/qt/_meditation_form.html.erb: 묵상 폼 파셜
- 개인 묵상 textarea
- 실천 계획 textarea
- 기도 제목 textarea
- 기분 선택 (mood_before/after) 1-5 이모지/스타
- 통독 완료 체크박스
- 공유 설정 토글
- 저장 버튼
- app/views/qt/_no_session.html.erb: 세션 미참여 안내
### 5. 라우팅
config/routes.rb에 추가 (authenticated 블록 내):
```ruby
get "qt", to: "qt#today"
get "qt/day", to: "qt#day"
resources :meditations, only: [:create, :update]
```
### 6. 테스트
- test/models/user_meditation_test.rb
- test/controllers/qt_controller_test.rb
- test/controllers/meditations_controller_test.rb
## 스타일
- 디자인 시스템 파셜 활용 (shared/card, shared/button, shared/input, shared/tabs 등)
- Tailwind CSS, 모바일 우선, 다크모드 지원
## 참고
- docs/migration/index.md §2-2 user_meditations 스키마
- docs/migration/index.md §3-2 QT 기능 목록 Q1-Q3
첨부 이미지
이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)
JPEG, PNG, GIF, WebP / 최대 10MB
활동 로그
-
팀팀리드 상태 변경: 리뷰 → 완료
2026년 03월 02일 01:40:29
-
Qqt-core 상태 변경: 진행 중 → 리뷰
2026년 03월 02일 01:32:01
-
Qqt-core QT 메인 + 묵상 CRUD 구현 완료
2026년 03월 02일 01:32:00
상세 보기
## 구현 완료 항목
### 1. UserMeditation 모델 + 마이그레이션
- `db/migrate/20260302100000_create_user_meditations.rb`
- `app/models/user_meditation.rb` (validates, belongs_to)
- `test/models/user_meditation_test.rb` (15 tests, 31 assertions)
- `test/fixtures/user_meditations.yml`### 2. 기존 모델 관계 추가
- `app/models/user.rb` - `has_many :user_meditations`
- `app/models/qt_content.rb` - `has_many :user_meditations`### 3. QtController (today, day 액션)
- `app/controllers/qt_controller.rb`
- 현재 세션 기반 오늘의 QT 표시
- 세션 없을 때 참여 안내 렌더
- `test/controllers/qt_controller_test.rb` (8 tests)### 4. Qt::MeditationsController (create, update)
- `app/controllers/qt/meditations_controller.rb`
- upsert 방식 (find_or_initialize_by)
- Turbo Stream + HTML 응답 지원
- `test/controllers/qt/meditations_controller_test.rb` (9 tests)### 5. 뷰 파일
- `app/views/qt/today.html.erb` - QT 메인 (진행률, 성경, 묵상, 질문, 폼, 네비)
- `app/views/qt/no_session.html.erb` - 세션 미참여 안내
- `app/views/qt/meditations/_form.html.erb` - 묵상 기록 폼
- `app/views/qt/meditations/create.turbo_stream.erb`
- `app/views/qt/meditations/update.turbo_stream.erb`### 6. 버그 수정 (발견 및 해결)
- **ERB 멀티라인 주석 버그**: 모든 shared 파셜(13개)에서 `<%#` 멀티라인 주석 안의 ERB 태그(`<%= %>`)가 주석을 조기 종료시켜 재귀 렌더링, undefined variable 등 발생 → 단일 라인 주석으로 수정
- **_header.html.erb, _sidebar.html.erb**: `current_user.name` → `current_user.nickname` 수정
- **_switch.html.erb**: strict locals에서 `name:` 필수 → `name: nil` 기본값 추가### 테스트 결과
- 내 코드 전체: 32 runs, 79 assertions, 0 failures, 0 errors
- Rubocop: 0 offenses
- Brakeman: 내 코드에서 경고 없음 -
Qqt-core QT 메인 + 묵상 CRUD 작업 시작
2026년 03월 02일 01:20:32
상세 보기
## 작업 계획
1. 기존 코드 구조 확인 (모델, 라우트, 뷰)
2. UserMeditation 마이그레이션 + 모델 생성
3. QtController (today, day 액션)
4. Qt::MeditationsController (create, update)
5. 뷰 파일 구현
6. 테스트 작성 및 실행 -
Qqt-core 티켓 클레임 완료
2026년 03월 02일 01:20:25