rails-service

Encapsulate Rails business logic in module-namespaced service classes.

Updated Oct 12, 2024
One-click install
npx skills add https://github.com/samrocks03/shuttle-office-service --skill rails-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-service
Source: https://github.com/samrocks03/shuttle-office-service/tree/main/.claude/skills/rails-service
Command: npx skills add https://github.com/samrocks03/shuttle-office-service --skill rails-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Encapsulates business logic in Rails by organizing module-namespaced service classes that inherit from a shared Base, ensuring controllers stay thin and all domain logic is centralized in app/services/.

Core Features & Use Cases

  • Module-namespaced services under a single pattern (e.g., WidgetService) with separate Create, Update, Destroy, Show, Index classes.
  • Base class provides standardized error handling, OpenStruct responses, and I18n integration; controllers delegate to services.
  • Use cases include CRUD workflows, complex business logic, and transactional operations that require consistent serialization.

Quick Start

Create a WidgetService::Create with your params and call it to perform a new widget creation.

Frequently Asked Questions about rails-service

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

FAQPage Schema
How do I encapsulate business logic in Rails to keep controllers thin?

Encapsulate business logic in Rails by organizing module-namespaced service classes that inherit from a shared Base, ensuring controllers delegate domain workflows to app/services and remain thin.

What is the best way to structure Rails service objects for CRUD operations?

Structure Rails service objects by grouping module-namespaced classes like Create, Update, Destroy, Show, and Index under a single domain pattern, all inheriting from a shared Base class for consistent behavior.

How does chainable method calling work with Rails service objects?

Chainable method calling in Rails service objects allows controllers to execute domain workflows sequentially, returning deterministic OpenStruct responses that include structured data, errors, and localized I18n messages.

Do I need a repository layer to use Rails service objects?

Yes, the Rails service object pattern depends on a repository layer for data access, working in tandem with ActiveRecord models to centralize persistence logic away from the service classes.

How do I handle error messages and serialization in Rails service objects?

Handle error messages and serialization in Rails service objects by using a shared Base class that provides standardized error handling, integrates I18n for localized messages, and returns deterministic OpenStruct responses.