vanilla-rails-routing
Use when defining Rails routes, organizing controller directories, or adding resources - enforces resource extraction, shallow nesting, resolve helpers, and module scoping
What this skill does
# Vanilla Rails Routing
**Routes mirror controller directory structure.** Every route points to a controller in the matching namespace.
## Resource Extraction (State as Resources)
State changes become singular nested resources, not custom actions:
```ruby
# Bad - custom actions
resources :cards do
post :close
post :archive
end
# Good - state as resource
resources :cards do
resource :closure, only: [:create, :destroy]
resource :archival, only: [:create, :destroy]
end
```
`resource` (singular) = one state per parent. `create` = enter state. `destroy` = leave state.
## Controller Directory Mapping
Route nesting mirrors `app/controllers/` directory:
```ruby
# routes.rb
resources :boards do
resources :cards do
resource :closure
end
end
# Maps to:
# app/controllers/boards_controller.rb
# app/controllers/boards/cards_controller.rb
# app/controllers/boards/cards/closures_controller.rb
```
**Rule:** If a route is nested under `boards`, the controller lives in `boards/` directory.
## Shallow Nesting
Avoid deeply nested URLs. Use `shallow:` or flatten when resource has its own identity:
```ruby
# Deep (avoid for >2 levels)
/boards/1/cards/2/comments/3/reactions/4
# Shallow
resources :boards do
resources :cards, shallow: true
end
# Produces:
# /boards/:board_id/cards (index, new, create)
# /cards/:id (show, edit, update, destroy)
```
**Rule:** If you can look up the resource by its own ID, it doesn't need parent in URL.
## Module Scoping
Group related controllers under modules for admin/API/etc:
```ruby
namespace :admin do
resources :accounts # Admin::AccountsController
end
scope module: :api do
resources :cards # Api::CardsController (no /api prefix in URL)
end
scope "/api" do
resources :cards # CardsController (with /api prefix, no module)
end
```
| Method | URL prefix | Module prefix | Use when |
|--------|-----------|---------------|----------|
| `namespace` | Yes | Yes | Admin panel, API versioning |
| `scope module:` | No | Yes | Alternate controller, same URL |
| `scope path:` | Yes | No | URL prefix, same controller |
## Resolve Helpers
Use `resolve` to control polymorphic URL generation:
```ruby
# Without resolve: url_for(@card) might generate wrong path
resolve("Card") { |card| [card.board, card] }
# Now polymorphic_path(@card) generates /boards/:board_id/cards/:id
```
Use when polymorphic routing needs explicit parent context.
## Direct Routes
Name custom routes for URL helpers:
```ruby
direct(:homepage) { "/" }
direct(:dashboard) { |account| "/#{account.to_param}/dashboard" }
# Usage: homepage_url, dashboard_url(@account)
```
## Quick Reference
| Pattern | Use | Avoid |
|---------|-----|-------|
| `resource :closure` | Singular state resource | `post :close` |
| `resources :cards, shallow: true` | 2+ nesting levels | Deep nesting >3 levels |
| `namespace :admin` | Admin/API sections | Manual path + module |
| `resolve("Card")` | Polymorphic URL control | String interpolation in paths |
| Controller at `boards/cards_controller.rb` | Nested route under boards | Controller location mismatch |
## Red Flags
- Custom member/collection actions for state changes → extract resource
- Controller file not matching route nesting → move controller
- 3+ levels of URL nesting → use `shallow:` or flatten
- `url_for` generating wrong paths → add `resolve`
- Route with no corresponding controller directory → create directory
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.