rails
Provides Rails reference distilled from 37signals' Fizzy: models, concerns, migrations, controllers, Hotwire, Solid Queue/Cache/Cable, Kamal, minitest. Use when working in a Rails codebase.
- License 许可
- MIT
- 最近更新
- 2026-11-04
- Stars
- ★ 4
- Forks
- 2
01 前言 Front Matter
- name
- rails
- group
- domain
- description
- Provides Rails reference distilled from 37signals' Fizzy: models, concerns, migrations, controllers, Hotwire, Solid Queue/Cache/Cable, Kamal, minitest. Use when working in a Rails codebase.
02 资源文件 29
- 参考文档active-storage.md10.2 KB
- 参考文档broadcasting.md6.2 KB
- 参考文档ci-and-linting.md5.9 KB
- 参考文档code-style.md4.7 KB
- 参考文档config-and-lib.md4.7 KB
- 参考文档controllers-errors-auth.md13.4 KB
- 参考文档controllers-rest.md12.1 KB
- 参考文档deploy-kamal.md11.6 KB
- 参考文档helpers.md6.4 KB
- 参考文档importmap-assets.md4.1 KB
- 参考文档jobs.md11.4 KB
- 参考文档mailers.md8.7 KB
- 参考文档models-attributes.md9.7 KB
- 参考文档models-callbacks-jobs.md7.1 KB
- 参考文档models-concerns.md7.9 KB
- 参考文档models-current-tenancy.md3.8 KB
- 参考文档models-migrations.md9.9 KB
- 参考文档models-structure.md9.4 KB
- 参考文档multi-tenancy.md8.2 KB
- 参考文档routes.md7.9 KB
- 参考文档solid-stack.md6.4 KB
- 参考文档stimulus.md6.6 KB
- 参考文档testing-controllers.md8.5 KB
- 参考文档testing-models-fixtures.md10.3 KB
- 参考文档testing-system-jobs-mailers.md11.0 KB
- 参考文档turbo.md6.1 KB
- 参考文档view-caching.md3.6 KB
- 参考文档view-components.md6.4 KB
- 参考文档views.md8.6 KB
03 SKILL.md 正文
Rails Reference
Rules
- Project RuboCop config wins. Fizzy uses
rubocop-rails-omakase, which enables neitherStyle/GuardClausenorLayout/IndentationConsistency, so lint enforces neither conditional style nor private indentation. Fizzy's STYLE.md is the 37signals default only when the project has no explicit rule; Fizzy's AGENTS.md calls its own instructions "defaults with reasons, not law". Use the project's.rubocop.ymlto resolve ambiguities. - Teach the project's Rails version. Fizzy runs Rails main (
rails 8.2.0.alpha) and aturbo-railsbranch (Gemfile.lock). Mark Fizzy-specific APIs that need Rails main (e.g.,Turbo.offline) where they appear, and do not use them in production. - Concerns for shared model behaviour. Put one capability of a model in a concern named for what it does (
Card::Closeable), and behaviour shared by several models inapp/models/concerns/. (Fizzy:app/models/card.rbincludes 23 concerns;app/models/concerns/) - Vanilla CRUD: prefer a new resource over a custom action. When an action doesn't fit a CRUD verb, introduce a resource (
resource :closure) instead of a custom route (post :close). (Fizzy STYLE.md "CRUD controllers") - Rich models, thin controllers, no service layer. Call model methods directly from controllers; avoid services unless strictly necessary. (Fizzy STYLE.md "Controller and model interactions")
- No
default_scope. Scope explicitly through relationships (Current.user.accessible_cards). Fizzy defines nodefault_scope: a search of the repository at the pinned commit finds none. (Fizzy:app/models/user/accessor.rb) Currentfor request-scoped context. Keep the session, user and account inCurrent(ActiveSupport::CurrentAttributes) and default model arguments from it (close(user: Current.user)). (Fizzy:app/models/current.rb,app/models/card/closeable.rb)- Solid stack, not Redis, for new apps. Use Solid Queue, Solid Cache and Solid Cable. Fizzy runs them on SQLite (
config/database.sqlite.yml) or MySQL (config/database.mysql.yml) and its Gemfile has no Redis gem. Redis is optional only if the app already depends on it (Sidekiq, caching). - Async work through
_laterplus shallow jobs. A model method that enqueues a job ends in_later, and the job'sperformcalls a plain model method (card.remove_inaccessible_notifications). STYLE.md names a synchronous twin*_now; Fizzy's models do not define one. (Fizzy STYLE.md "Run async operations in jobs";app/jobs/card/remove_inaccessible_notifications_job.rb) - Minitest and fixtures. Fizzy uses Minitest (Rails default) and fixtures, with no factories:
test/fixtures/exists and the Gemfile has no RSpec or FactoryBot. - ViewComponent only if the project already uses it. Added by the owner, not from Fizzy/37signals. Don't introduce it to projects that use partials: Fizzy renders with partials and helpers and has no
view_componentgem orapp/components.
Provenance: distilled from Fizzy (github.com/basecamp/fizzy) at commit 6aebc0cea63d0e5fcdd2eeea138072ddcb26be74, reviewed 2026-10-05. Also drawn from Fizzy's STYLE.md, AGENTS.md and dev.37signals.com articles; ViewComponent (view-components.md) is not from Fizzy.
Models
| File | Read when … |
|---|---|
| models-structure.md | Setting up models, associations (including delegated types), file structure, and model templates |
| models-callbacks-jobs.md | Writing callbacks and enqueueing jobs from models via _later suffix |
| models-attributes.md | Validating attributes, enums, serialization, secure tokens, Action Text, UUID primary keys |
| models-concerns.md | Organizing model capabilities as concerns (feature and shared) |
| models-current-tenancy.md | Using Current attributes in models and controllers, account-scoped associations, global identity records |
| models-migrations.md | Writing and structuring database migrations, indexes, foreign keys |
Controllers, Routes and Helpers
| File | Read when … |
|---|---|
| controllers-rest.md | Building REST controllers (CRUD, resource-action, nested), parameter handling, response patterns |
| controllers-errors-auth.md | Error handling, performance, API patterns, security, authentication in controllers |
| routes.md | Routing: resources, custom routes, nested routes, namespaces, resource vs. custom action |
| helpers.md | View helpers: application, domain-specific, form, time helpers and best practices |
Views and Frontend
| File | Read when … |
|---|---|
| views.md | Writing ERB templates, partials, layouts, forms, helpers, and Jbuilder |
| view-caching.md | Fragment caching, HTTP caching with ETags, touch chains, Jbuilder caching |
| view-components.md | Using ViewComponent (added by the owner, not from Fizzy/37signals). Skip unless the project already uses it. |
| stimulus.md | Stimulus controllers: structure, patterns (auto-submit, keyboard, dialog, toggle), file organization |
| turbo.md | Turbo Frames and Streams: lazy-load, morphing, refresh broadcasts, prefetch, view transitions |
| broadcasting.md | Broadcasting model changes: broadcasts_refreshes, *_later_to methods, Solid Cable config, multi-tenant |
| importmap-assets.md | Importmap (JS pinning, audits), Propshaft (plain CSS, no build), Thruster (reverse proxy) |
| active-storage.md | File attachments: variants, validations, storage services (S3, local, GCS) |
Jobs, Mail and Storage
| File | Read when … |
|---|---|
| jobs.md | Active Job and Solid Queue: job structure, _later jobs, recurring jobs, error handling, testing |
| mailers.md | Action Mailer: structure, templates, previews, sending async, testing |
Infrastructure and Deploy
| File | Read when … |
|---|---|
| solid-stack.md | Solid Queue, Solid Cache, Solid Cable: configuration, databases, migrations |
| deploy-kamal.md | Kamal 2 deployment: config/deploy.yml, Dockerfile, Thruster, entrypoint, secrets, hooks |
| config-and-lib.md | Initializers, lib/ structure, Rails extensions, custom libraries |
| multi-tenancy.md | URL-based tenancy (the one home for tenancy code): routing, middleware, Current, tenant-aware mailers, cable, jobs, test setup |
Testing
| File | Read when … |
|---|---|
| testing-models-fixtures.md | Model tests, fixtures, test structure, test helpers, running tests |
| testing-controllers.md | Controller and integration tests, permissions, response formats |
| testing-system-jobs-mailers.md | System tests (Capybara), job tests, mailer tests, helper tests |
Style and CI
| File | Read when … |
|---|---|
| code-style.md | Code formatting: RuboCop config, conditionals, method order, bang methods, visibility |
| ci-and-linting.md | CI setup, GitHub Actions, RuboCop configuration, pre-commit hooks |
Overlapping Files
- multi-tenancy.md holds the tenancy code once (middleware,
Current,AccountTenanted, test setup); models-current-tenancy.md coversCurrentuse in models and controllers and account-scoped associations. - models-callbacks-jobs.md covers enqueueing jobs from models via
_later; jobs.md covers job classes, queue configuration, and Solid Queue.
04 同仓库更多 Skills
security-audit
Audits a codebase for security vulnerabilities, independently verifies each one, and writes a report. Use when asked for a full, multi-phase codebase security audit or pen test, or for focused security guidance on code.
wayfinder
Charts a map of investigation tickets on the issue tracker for work too big for one agent session, then resolves them one per session. Use when the user wants to wayfind a large loose idea or continue an existing wayfinder map.
triage
Triages issues and external PRs: categorises, verifies, grills if needed, and writes agent-ready briefs. Use when the user wants to triage the backlog or a specific issue or PR.
to-tickets
Breaks a plan, spec or conversation into tracer-bullet tickets, each declaring its blocking edges, and publishes them to the configured tracker. Use when the user wants a spec or plan turned into tickets or issues.
to-spec
Turns the current conversation into a spec and publishes it to the project issue tracker, with no interview, only synthesis of what was discussed. Use when the user wants the discussion written up as a spec.
setup-agent-tracker
Configures a repo's issue tracker, triage label vocabulary and domain doc layout for the agent-notes workflow skills. Use when starting in a new repo, once, before triage, to-spec, to-tickets or wayfinder.