rails-routes

Guide Rails routing with RESTful resources, nested scopes, and route constraints.

4|2|Updated Dec 12, 2025
One-click install
npx skills add https://github.com/rubakas/agent-notes --skill rails-routes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-routes
Source: https://github.com/rubakas/agent-notes/tree/main/rails-routes
Command: npx skills add https://github.com/rubakas/agent-notes --skill rails-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rails routing complexity leads to misconfigured URLs and hard-to-maintain code. This Skill provides a structured guide to RESTful resources, nested routes, and clean URL organization to keep Rails apps scalable and predictable.

Core Features & Use Cases

  • RESTful Resources: Treat all entities as resources with standard actions for consistency.
  • Actions as Resources: Use singleton resources for state toggles instead of custom routes.
  • Nested & Scoped Routing: Organize controllers with scope module and nest resources to reflect domain structure.
  • Namespaces vs Scope Modules: Choose the right balance to keep URLs clean and code modular.
  • Testing Patterns: Validate routes with tests to ensure correct mappings and guards.

Quick Start

In your project's CLAUDE.md, reference @agent-notes/rails-routes/index.md to load these routing patterns.

Frequently Asked Questions about rails-routes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure nested resources in Rails routes for complex domain models?

Use scope module in Rails routes to group controllers under a module without adding URL path prefixes, keeping URLs clean while organizing controller code by domain boundaries or functional areas.

When should I use singleton resources instead of standard RESTful resources in Rails?

Use singleton resources in Rails for state toggles or single-instance actions instead of custom routes, enforcing RESTful conventions by treating state changes as resources with standard show and update actions.

What is the difference between namespaces and scope module in Rails routing?

Namespaces in Rails routing add a URL path prefix and module namespace to controllers, while scope module only sets the controller module namespace without altering the URL path, balancing clean URLs against modular code.

How do I test Rails routes to ensure correct mappings and guards?

Test Rails routes using routing tests to assert HTTP verbs map to correct controller actions and that route constraints and guards enforce predictable behavior for standard, nested, and singleton resource definitions.

Can I use route concerns to simplify repeated routing patterns in Rails?

Route concerns in Rails let you define reusable routing blocks for common patterns, then include them across multiple resources to keep complex route graphs DRY and maintainable.