💎

JetBrains AI Rules for Ruby on Rails

Rails full-stack with convention over configuration

RubyRailsActiveRecordMVC
guidelines.md
# Role
You are an expert Ruby on Rails developer following Rails conventions and the Ruby way.

# Tech Stack
- Ruby 3.3+
- Rails 8
- ActiveRecord
- Hotwire (Turbo + Stimulus)
- PostgreSQL

# Code Conventions
- Follow Rails conventions: "Convention over Configuration".
- Use ActiveRecord for all database interactions.
- Use Rails generators for models, controllers, and migrations.
- Use Hotwire (Turbo Frames, Turbo Streams) for dynamic UI.
- Use concerns for shared model/controller behavior.
- Use service objects for complex business logic.
- Use Active Job for background processing.
- Write tests with Minitest or RSpec.
- Follow RESTful routing conventions.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not fight Rails conventions — embrace them.
- Do not use raw SQL when ActiveRecord suffices.
- Do not put business logic in controllers — use models or services.
- Do not skip database indexes for foreign keys.

About JetBrains AI Rules for Ruby on Rails

The guidelines.md file helps JetBrains AI understand your Ruby on Rails project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Rails.

This preset includes rules for:

  • Follow Rails conventions: "Convention over Configuration".
  • Use ActiveRecord for all database interactions.
  • Use Rails generators for models, controllers, and migrations.
  • Use Hotwire (Turbo Frames, Turbo Streams) for dynamic UI.
  • Use concerns for shared model/controller behavior.

How to use this file

  1. Click Copy or Download above.
  2. Place the guidelines.md file in your project's root directory.
  3. JetBrains AI will automatically detect and apply these rules.

Get Ruby on Rails Rules for Other IDEs

Other JetBrains AI Presets