一键导入
controller-routes
Add controllers and routes following project patterns for organizer namespaces, strong params, and Turbo
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add controllers and routes following project patterns for organizer namespaces, strong params, and Turbo
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Create and manage Solid Queue background jobs with perform_now vs perform_later patterns
Perform deep critical analysis of changes with focus on performance vs sustainability trade-offs
Build Rails forms with Tailwind CSS, Turbo integration, and strong params validation
Write database migrations for PostgreSQL with PostGIS, UUID primary keys, enums, and counter caches
Create and modify Rails models following project conventions for STI, enums, validations, counter caches, and scopes
Create service objects in app/services/ using module namespaces for encapsulation
基于 SOC 职业分类
| name | controller-routes |
| description | Add controllers and routes following project patterns for organizer namespaces, strong params, and Turbo |
| license | MIT |
config/routes.rb with nested resourcesparams.expect# Public routes
resources :tournaments, only: %i[index show] do
resources :rounds, only: [] do
resources :pods, only: [] do
resources :results
end
end
resources :event_participants do
collection { get "me" }
end
end
# Organizer namespace (requires authentication + organizer role)
namespace :organizer do
root "tournaments#index"
resources :tournaments do
resources :rounds do
resources :pods do
resources :results
resources :infractions, only: %i[new create]
end
resources :seatings, only: [] do
patch :swap, on: :collection
end
end
resources :event_participants do
resources :infractions, only: %i[index destroy]
end
end
resources :leagues do
# same nesting as tournaments
post :create_pickup_pod, on: :member
end
end
root "events#index"
ApplicationController < ActionController::Base
└── Organizer::OrganizerController < ApplicationController
├── Organizer::TournamentsController
├── Organizer::LeaguesController
├── Organizer::CircuitsController
├── Organizer::RoundsController
├── Organizer::ResultsController
├── Organizer::InfractionsController
├── Organizer::SeatingsController
└── Organizer::EventParticipantsController
# app/controllers/organizer/organizer_controller.rb
module Organizer
class OrganizerController < ApplicationController
before_action :authorize_user!
def authorize_user!
redirect_to root_url, alert: "Not allowed" unless current_user.organizer?
end
def current_organizer
current_user.event_organizer
end
end
end
# frozen_string_literal: true
module Organizer
class ResourceController < OrganizerController
def index
@items = Model.for_organizer(current_organizer).preload(:associations)
end
def new
@item = Model.new
end
def create
@item = Model.create(resource_params.merge(event_organizer: current_organizer))
redirect_to [:organizer, @item], notice: "Created"
rescue => e
# Handle error
end
def edit
@item = Model.for_organizer(current_organizer).find(params[:id])
end
def update
@item = Model.for_organizer(current_organizer).find(params[:id])
@item.attributes = resource_params
if @item.save
redirect_to [:organizer, @item], notice: "Updated"
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@item = Model.for_organizer(current_organizer).find(params[:id])
@item.destroy
redirect_to index_path, notice: "Deleted"
rescue ActiveRecord::RecordNotFound
redirect_to index_path, alert: "Not found"
end
private
def resource_params
params.expect(resource: %i[field1 field2])
end
end
end
params.expect(:model, [:fields]) instead of params.require(...).permit(...)params.expect(tournament: %i[name state])for_organizer(current_organizer) scope on models for scopingrescue ActiveRecord::RecordNotFound in show/edit/update → redirect to indexcurrent_organizer helper in OrganizerController base classapplicationlayout "modal", only: %i[new edit] in ApplicationController<%= turbo_frame_tag "modal", target: "_top" %> in layoutpreload or includes in index/show actions.preload(rounds: :pods, event_participants: { player: :user })config/routes.rb — Full routes structureapp/controllers/organizer/organizer_controller.rb — Auth base classapp/controllers/organizer/tournaments_controller.rb — Example controller with strong paramsapp/controllers/concerns/authentication.rb — Auth concern