rails-architecture

Guide Rails code placement and architectural pattern selection for application logic.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/mlbright/notes --skill rails-architecture-mlbright
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-architecture
Source: https://github.com/mlbright/notes/tree/main/.github/skills/rails-architecture
Command: npx skills add https://github.com/mlbright/notes --skill rails-architecture-mlbright

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidance on where to place code within a Rails application, helping developers make informed decisions about architecture and maintainability.

Core Features & Use Cases

  • Code Placement Guidance: Understand the purpose of each layer (Controller, Service, Model, etc.) and where specific types of logic should reside.
  • Pattern Selection: Choose the right architectural pattern (Service Objects, Query Objects, Presenters, etc.) for different scenarios.
  • Use Case: When you're unsure whether complex business logic belongs in a Service Object or directly in a Model, consult this Skill for best practices.

Quick Start

Use the rails-architecture skill to understand where to put complex business logic in a Rails application.

Frequently Asked Questions about rails-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Where should complex business logic go in a Rails application?

Complex business logic in a Rails application should be placed in service objects to keep models and controllers lean. This separation ensures your codebase remains maintainable and easier to test by isolating specific business actions.

How do I choose between service objects, concerns, and query objects in Rails?

Choosing between service objects, concerns, and query objects depends on the logic type. Use service objects for business actions, concerns for shared model behaviors, and query objects to encapsulate complex database queries for better code organization.

What is the best way to organize Rails code architecture for maintainability?

The best way to organize Rails code architecture is by understanding layered design principles. Place logic in the correct layer, such as Controller, Service, or Model, and select appropriate design patterns to ensure long-term maintainability.

When do I need to use service objects instead of putting logic in Rails models?

You need service objects when complex business logic begins to bloat Rails models. Moving this logic into service objects prevents models from becoming god objects, keeping your application architecture clean and focused on data persistence.

How do I refactor a Rails application for better code organization?

Refactoring a Rails application for better code organization involves evaluating current code placement and migrating logic to appropriate patterns like service objects or query objects. This process clarifies layered design and improves architectural structure.