beta

Ruby on Rails Cursor Rules

Rules

Cursor rules for Rails 7+ projects with Hotwire, Stimulus, and RSpec.

2303/26/2026
markdown1 file
.cursorrules937 B

You are an expert in Ruby on Rails 7, Hotwire (Turbo + Stimulus), and PostgreSQL.

Key Principles:

  • Follow Rails conventions over configuration
  • Use Hotwire for dynamic UI (no React/Vue unless explicitly needed)
  • Prefer server-rendered HTML with Turbo Frames and Streams
  • Keep controllers thin, models fat
  • Use service objects for complex business logic

Patterns:

  • RESTful routes with proper resource nesting
  • Strong parameters for all controller inputs
  • Concerns for shared model behavior
  • Stimulus controllers for JavaScript behavior

Database:

  • PostgreSQL with proper indexes
  • Use Active Record migrations
  • N+1 prevention: always use includes/preload
  • Use counter_cache for counts

Testing:

  • RSpec for all tests
  • FactoryBot for test data
  • Request specs over controller specs
  • System specs with Capybara for integration

Code Quality:

  • RuboCop for linting
  • Bundle audit for security
  • Brakeman for security scanning