Curriculum CRUD — Admin 컨트롤러 + 뷰 + position 정렬 + published 필터 + 테스트
ID: 64f881e7-e8e2-4070-a014-e7e11cc0b704
## 목표
Admin 네임스페이스에서 Curriculum CRUD 완전 구현. position 기반 정렬, published 토글.
## 현재 상태
- Curriculum 모델 존재: title, description, week_start, week_end, position, published. has_many :lessons, validates, scope :published
- Admin::CurriculaController 스텁 존재 (빈 액션)
- Admin::BaseController 존재 (require_admin before_action)
- 라우트: `namespace :admin { resources :curricula do resources :lessons end }`
- 공용 Partial: _button, _card, _input, _flash, _navbar
## 구현 사항
### 1. Admin::CurriculaController 완전 구현
```ruby
class Admin::CurriculaController < Admin::BaseController
before_action :set_curriculum, only: [:show, :edit, :update, :destroy]
def index
@curricula = Curriculum.order(:position)
# published 필터 파라미터 지원: ?filter=published / ?filter=unpublished
end
def show; end
def new
@curriculum = Curriculum.new
end
def create
@curriculum = Curriculum.new(curriculum_params)
if @curriculum.save
redirect_to admin_curriculum_path(@curriculum), notice: "커리큘럼이 생성되었습니다."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @curriculum.update(curriculum_params)
redirect_to admin_curriculum_path(@curriculum), notice: "커리큘럼이 수정되었습니다."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@curriculum.destroy
redirect_to admin_curricula_path, notice: "커리큘럼이 삭제되었습니다."
end
private
def set_curriculum
@curriculum = Curriculum.find(params[:id])
end
def curriculum_params
params.require(:curriculum).permit(:title, :description, :week_start, :week_end, :position, :published)
end
end
```
### 2. 뷰 (app/views/admin/curricula/)
- **다크 테마** (앱 내부 — bg-bg, text-text-primary, bg-surface)
- 기존 Partial 활용 (_button, _card, _input)
- index: 테이블 형태 목록 (position 순서), published 필터 탭, 새로 만들기 버튼
- show: 커리큘럼 상세 + 하위 레슨 목록 (있으면)
- new/edit: 폼 (_form partial 공유)
- _form: title, description, week_start, week_end, position, published 체크박스
### 3. published 필터
- index에서 ?filter=published, ?filter=unpublished, 기본은 전체
- 탭 UI로 구현
### 4. position 기반 정렬
- index에서 Curriculum.order(:position)
- 폼에서 position 입력 가능
### 5. Admin 레이아웃
- Admin 전용 네비게이션이 필요하면 간단히 추가 (사이드바 또는 상단 탭)
- 최소한 Admin 제목 + 뒤로가기 링크
### ⚠️ 주의
- developer-2가 동시에 Build::ProjectsController 작업 중 — admin/ 범위만 수정
- 모델(curriculum.rb)은 이미 완성됨 — 모델 수정 불필요 (Curriculum 모델에 추가 scope 필요하면 가능)
- User 모델 건드리지 않기
- 한국어 Flash 메시지
### 테스트 (TDD)
- Admin::CurriculaController 테스트:
- admin 유저만 접근 가능 (non-admin → 리다이렉트)
- CRUD 전체 동작 (create, read, update, destroy)
- published 필터 동작
- position 순서 정렬 확인
- 유효하지 않은 입력 시 에러 표시
- fixture: curricula.yml에 이미 데이터 있을 것 — 확인 후 사용
### 완료 기준
- Admin 커리큘럼 CRUD 전체 동작
- published/unpublished 필터
- position 기반 정렬
- 컨트롤러 테스트 통과
- bin/rails test 전체 통과
첨부 이미지
이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)
JPEG, PNG, GIF, WebP / 최대 10MB
활동 로그
-
Ddeveloper-1 상태 변경: 할 일 → 리뷰
2026년 03월 26일 08:24:55