diff --git a/config/project-stack-mappings.json b/config/project-stack-mappings.json index 46fe11e32..6c90c6e6c 100644 --- a/config/project-stack-mappings.json +++ b/config/project-stack-mappings.json @@ -359,6 +359,7 @@ ], "rules": ["common"], "skills": [ + "rails-patterns", "tdd-workflow", "verification-loop" ], diff --git a/skills/rails-patterns/SKILL.md b/skills/rails-patterns/SKILL.md index 5133e8ab4..876df985a 100644 --- a/skills/rails-patterns/SKILL.md +++ b/skills/rails-patterns/SKILL.md @@ -163,8 +163,8 @@ module Invoices def build_invoice invoice = user.invoices.new(params.except(:line_items)) - invoice.tax_total = TaxCalculator.call(invoice) invoice.line_items.build(params[:line_items]) + invoice.tax_total = TaxCalculator.call(invoice) invoice.total = invoice.line_items.sum(&:amount) + invoice.tax_total invoice end @@ -258,7 +258,7 @@ Query objects accept a scope, so they compose: `Invoices::Overdue.call(scope: cu @posts = Post.published.includes(:author) ``` -`includes` lets Rails choose preload vs eager_load. Force `preload` for separate queries, `eager_load` for a JOIN when filtering on the association. In Rails 7.1+, `strict_loading` raises on accidental lazy loads. +`includes` lets Rails choose preload vs eager_load. Force `preload` for separate queries, `eager_load` for a JOIN when filtering on the association. Since Rails 6.1, `strict_loading` raises on accidental lazy loads. ### Counter cache @@ -472,5 +472,4 @@ If the page is server-rendered with occasional interactivity, Hotwire ships fast ## Related Skills - `backend-patterns` — service boundaries and adapter patterns (referenced by the Ruby patterns rules) -- `ruby-patterns` — language-level Ruby idioms (if present) - Ruby patterns rules (`rules/ruby/patterns.md`, installed as `rules/ecc/ruby/patterns.md`) — the decisions and when-to-use guidance this skill implements