Admin Products 라우트 + 컨트롤러 구현

ID: b4837b64-5597-4e13-b7ee-552dc3848cbb

높음 완료

Admin::ProductsController CRUD 구현

## 수정 파일
- config/routes.rb: admin 네임스페이스에 resources :products 추가 (toggle_active member 라우트 포함)
- app/controllers/admin/products_controller.rb: 새 파일 생성

## 컨트롤러 요구사항
- Admin::BaseController 상속 (require_admin 자동 적용)
- 액션: index, show, new, create, edit, update, toggle_active
- index: 검색(q param, name ILIKE), 필터(product_type, active), 정렬(sort/direction), 페이지네이션(PER_PAGE=30)
- show: @product with product_prices eager load
- create/update: strong params (name, slug, description, price, currency, product_type, active, product_prices_attributes[id, currency, amount, _destroy])
- toggle_active: active 토글 후 redirect
- accepts_nested_attributes_for :product_prices (모델에 추가 필요)
- flash 메시지: notice/alert, i18n 키 사용
- 기존 Admin::WorkspacesController 패턴 참고

## 완료 기준
- rails routes | grep admin/products 로 라우트 확인
- 컨트롤러 파일이 기존 패턴과 일관성 있음

첨부 이미지

이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)

JPEG, PNG, GIF, WebP / 최대 10MB

담당자: backend-dev
생성일: 2026년 02월 28일 07:24

활동 로그

  • 팀리드 상태 변경: 리뷰 → 완료

    2026년 02월 28일 07:39:23

  • B
    backend-dev 상태 변경: 할 일 → 리뷰

    2026년 02월 28일 07:27:38

  • B
    backend-dev 라우트 + 컨트롤러 + 모델 수정 완료

    2026년 02월 28일 07:27:34

    상세 보기

    ## 변경 사항

    ### 1. app/models/product.rb
    - `accepts_nested_attributes_for :product_prices, allow_destroy: true` 추가

    ### 2. config/routes.rb
    - admin 네임스페이스에 `resources :products, except: :destroy` 추가
    - `member { patch :toggle_active }` 추가

    ### 3. app/controllers/admin/products_controller.rb (신규)
    - Admin::BaseController 상속
    - 액션: index, show, new, create, edit, update, toggle_active
    - index: 검색(q→name ILIKE), 필터(product_type, active), 정렬, 페이지네이션(PER_PAGE=30)
    - show: includes(:product_prices)
    - create/update: nested product_prices_attributes 지원
    - toggle_active: toggle!(:active)
    - flash 메시지: I18n.t 사용

    ### 참고
    - workspaces_controller.rb 패턴 동일하게 적용
    - 라우트 확인 완료 (bin/rails routes)