model-patterns

Guide building rich Ruby on Rails domain models with validations, callbacks, and associations.

Updated Jun 9, 2026
One-click install
npx skills add https://github.com/arthun01/achados-uesc --skill model-patterns-arthun01
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: model-patterns
Source: https://github.com/arthun01/achados-uesc/tree/main/.opencode/skills/model-patterns
Command: npx skills add https://github.com/arthun01/achados-uesc --skill model-patterns-arthun01

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides guidance on building rich domain models in Ruby on Rails, enhancing the maintainability and scalability of applications.

Core Features & Use Cases

  • Rich Domain Models: Encapsulate business logic within models for a more maintainable codebase.
  • Fat Models Over Service Objects: Apply the fat-models-over-service-objects philosophy to organize code effectively.
  • Use Cases: Ideal for creating models, adding validations, scopes, callbacks, business logic methods, or associations.

Quick Start

Use the model-patterns skill to generate a new model with the following command: bin/rails generate model Card title:string body:text board:references:uuid.

Frequently Asked Questions about model-patterns

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

FAQPage Schema
How do I organize business logic in Rails models instead of using service objects?

To organize business logic in Rails models, apply the fat-models-over-service-objects philosophy by encapsulating domain logic, validations, and callbacks directly within your ActiveRecord models for better maintainability.

What is the best way to structure rich domain models in Ruby on Rails?

The best way to structure rich domain models in Ruby on Rails is to encapsulate business logic, associations, and validations within the models themselves, ensuring a scalable and maintainable application architecture.

How do I add validations and callbacks to a Ruby on Rails model?

You add validations and callbacks to a Ruby on Rails model by following best practices for domain modeling, which involves defining these rules and triggers directly inside the model class to manage data integrity and lifecycle events.

When should I use fat models over service objects in Ruby on Rails?

You should use fat models over service objects in Ruby on Rails when your goal is to encapsulate domain logic directly within your models, creating a more maintainable codebase without the overhead of separate service classes.

How do I generate a new Rails model with associations and specific column types?

You generate a new Rails model with associations by using the Rails generate model command, such as `bin/rails generate model Card title:string body:text board:references`, to define attributes and relationships immediately.