dhh-rails-style

Apply DHH Rails conventions to Ruby and Rails projects.

Updated Dec 21, 2023
One-click install
npx skills add https://github.com/Hff1230/FFNotes --skill dhh-rails-style-hff1230
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dhh-rails-style
Source: https://github.com/Hff1230/FFNotes/tree/main/AI%E5%BA%93/Skill/compound-engineering-zh/skills/dhh-rails-style
Command: npx skills add https://github.com/Hff1230/FFNotes --skill dhh-rails-style-hff1230

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

DHH Rails style provides a disciplined blueprint for writing Ruby and Rails code by emphasizing RESTful resources, slim controllers, and state as records, enabling maintainable and scalable Rails applications aligned with 37signals conventions.

Core Features & Use Cases

  • RESTful resource design: map actions to resources via standard CRUD and nested routes.
  • Controller and model discipline: lean controllers, concerns for shared behavior, and state recorded as separate models (e.g., Closure, Goldness) to improve auditability.
  • Architecture and testing: multi-tenancy, Turbo/Stimulus front-end cues, Minitest with fixtures, and solid queue/cache choices to simplify infrastructure.
  • Code review guidance: practical tips for applying DHH style during code reviews and general guidance.

Quick Start

Provide a step-by-step plan to apply DHH Rails style to an existing Rails project, focusing on RESTful routes, lean controllers, and stateful models.

Frequently Asked Questions about dhh-rails-style

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

FAQPage Schema
How do I apply DHH Rails style to an existing Ruby on Rails project?

To apply DHH Rails style, refactor your existing Ruby on Rails project to use resource-based routing, lean controllers, and stateful models. This involves mapping actions to standard CRUD routes and extracting shared behavior into concerns.

Why use concerns and Current attributes in Rails architecture?

Concerns and Current attributes in Rails architecture promote lean controllers and model-first state. By recording state as separate models, you improve auditability and maintainability while adhering to 37signals conventions for shared behavior.

What is the best way to structure multi-tenant Rails apps with Turbo?

The best way to structure multi-tenant Rails apps with Turbo is to follow RESTful resource design and use Minitest with fixtures. This approach simplifies infrastructure by leveraging solid queue and cache choices aligned with Rails conventions.

Does DHH Rails style work with Minitest and fixtures instead of RSpec?

Yes, DHH Rails style works with Minitest and fixtures. It advocates for a minimal, Rails-aligned gem ecosystem, deliberately choosing Minitest and fixtures over heavier testing frameworks to simplify testing infrastructure.

Can I use DHH Rails conventions for code reviews in Ruby projects?

Yes, you can use DHH Rails conventions for code reviews in Ruby projects. The style provides practical code review guidance to enforce RESTful design, lean controllers, and stateful models, ensuring maintainable code.

When should I not use concerns for shared behavior in Rails models?

You should avoid using concerns in Rails models when the shared behavior does not map cleanly to a RESTful resource or when it obscures model-first state. DHH style favors recording state as separate records rather than forcing logic into concerns.