1002-rails-models

1002-rails-models is a cursor rule for Cursor from andyw8/rails_rules. It costs 0 tokens per session (682 once invoked), scanned A, original, MIT.

A set of Rails 8 rules for database-backed model classes, which represent and validate stored application data. It covers project conventions such as typed attributes, relationships, JSON fields, and documentation.

In plain words
What is it for?
Creating or modifying Rails models, adding validations and relationships, handling JSON or UUID fields, documenting methods, and passing models to background jobs.
Why use it?
It helps new or changed models fit the application's existing structure and avoids inconsistent Rails patterns.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Creating or modifying Rails models, adding validations and relationships, handling JSON or UUID fields, documenting methods, and passing models to background jobs.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/andyw8/rails_rules/1002-rails-models
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/andyw8/rails_rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 1002-rails-models

README.md
[![agentmods](https://agentmods.dev/badge/rules/andyw8/rails_rules/1002-rails-models/github.svg)](https://agentmods.dev/rules/andyw8/rails_rules/1002-rails-models)
Your own site
<a href="https://agentmods.dev/rules/andyw8/rails_rules/1002-rails-models"><img src="https://agentmods.dev/badge/rules/andyw8/rails_rules/1002-rails-models/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for 1002-rails-models

Your own site · 80×15
<a href="https://agentmods.dev/rules/andyw8/rails_rules/1002-rails-models"><img src="https://agentmods.dev/badge/rules/andyw8/rails_rules/1002-rails-models.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 682 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00682
Opus 5.5 $0.00000 $0.00273
Sonnet 5.5 $0.00000 $0.00136
Haiku 4.5 $0.00000 $0.00068

Measured 1mo ago against content hash e97b5897bef4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

1002-rails-models scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

lib/generators/rails_rules/templates/1002-rails-models.mdc · 106 lines

How it starts

The opening of the file, as written. The whole thing — 106 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rails Model Standards

Context

  • In Ruby on Rails 8.0 models
  • Use modern Rails patterns like store_accessor, concerns, and modules
  • Add YARD documentation

Requirements

  • Add YARD documentation to all methods
  • Use positional arguments in enums
  • Include a separate module for specific roles, validations, or other functionality
  • Define constants at the top of the file
  • Use has_prefix_id for models with UUIDs
  • Use strong typing with attribute declarations
  • Use normalizes for attribute normalization
  • Include Searchable concern for models that need search
  • Use counter_cache for belongs_to relationships that need counts
  • Use store_accessor for models with JSON columns
  • Use acts_as_tenant for multi-tenant models
  • Include validation for uploaded files with resizable_image
  • Pass models to jobs, not IDs (they will be serialized)
  • Use strong typing in models with attribute declarations

Examples

class Plan < ApplicationRecord has_prefix_id :plan

INTERVALS = [:month, :year].freeze

Store JSON attributes in the details column

@return [Array] List of features for this plan

store_accessor :details, :features, :stripe_tax

Define default attributes

attribute :currency, default: "usd"

Normalize attributes before saving

normalizes :currency, with: ->(currency) { currency.downcase }

Validations

validates :name, :amount, :interval, presence: true validates :currency, presence: true, format: {with: /\A[a-zA-Z]{3}\z/, message: "must be a 3-letter ISO currency code"} validates :interval, inclusion: INTERVALS validates :trial_period_days, numericality: {only_integer: true} validates :unit_label, presence: {if: :charge_per_unit?}

Scopes

scope :hidden, -> { where(hidden: true) } scope :visible, -> { where(hidden: [nil, false]) } scope :monthly, -> { where(interval: :month) } scope :yearly, -> { where(interval: :year) } scope :sorted, -> { order(amount: :asc) }

Returns a list of features for this plan

@return [Array] List of features

def features Array.wrap(super) end

Checks if this plan has a trial period

@return [Boolean] True if the plan has a trial

def has_trial? trial_period_days > 0 end

Checks if this plan is a monthly plan

@return [Boolean] True if the plan is monthly

def monthly? interval == "month" end end

</example>

Read the full file on GitHub · 106 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 106 lines · 0 tokens per session scan A e97b5897bef4

Subscribe to this mod's changes

1002-rails-models is a cursor rule published in the GitHub repository andyw8/rails_rules (4 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 682 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.