Rails Active Record 8.0
Last reviewed Sep 24, 2026
Prompt Details
Prompt Composition
3prompts
- Ruby 3.4122 lines · 4K tokens
- Ruby on Rails 8.079 lines · 3.6K tokens
- Rails Active Record 8.080 lines · 3.8K tokens
Total281 lines · 11.4K tokens
CWE Coverage
- 20
- 23
- 59
- 73
- 74
- 78
- 79
- 89
- 95
- 113
- 117
- 122
- 134
- 208
- 209
- 214
- 250
- 295
- 306
- 307
- 312
- 319
- 327
- 338
- 347
- 352
- 362
- 367
- 378
- 384
- 409
- 426
- 434
- 470
- 502
- 532
- 552
- 566
- 601
- 613
- 614
- 639
- 749
- 770
- 772
- 807
- 829
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1333
- 1395
Prompt Preview
Apply the Ruby on Rails 8.0 prompt first. These rules cover Active Record 8.0 and were checked against 8.0.5.1, which requires Ruby 3.2.0 or newer; the included Rails pack selects the Ruby 3.4 baseline.
Query construction and bounded reads
- Construct
where,having, andfind_byconditions yourself, using attribute hashes or placeholders such aswhere("email = ?", email). Never pass a request-supplied string or entire parameter object as the condition. - Keep SQL structure in
order,group,select,pluck,joins, andfromserver-owned. ReviewArel.sql, custom Arel nodes,find_by_sql, and connection-level query APIs as SQL escape hatches; bind values and map selectable identifiers or expressions to fixed alternatives. - Escape literal search text with
sanitize_sql_likebefore adding intentional%wildcards to a boundLIKEvalue; quoting alone does not neutralize%or_pattern matching. - Preserve mandatory predicates through
merge,or, subqueries, eager loading, and association traversal. Reviewunscoped,unscope,except, andrewhere; do not callinvert_whereon a relation containing tenant or visibility predicates, because it negates the accumulated conditions. - Fail closed when an authorization predicate cannot be built: raise or return
none.where(nil),where({}), and other blank conditions leave the relation unchanged. - Do not rely on an ordinary
default_scopeto constrain instance updates or deletes;all_queries: trueis needed to apply its WHERE predicates to those operations. Even that scope can be