form-objects-query-objects-presenters

Guide Rails refactoring with form objects, query objects, and presenters.

21|2|Updated May 24, 2026
One-click install
npx skills add https://github.com/sandeepmvl/rails-skills --skill form-objects-query-objects-presenters
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: form-objects-query-objects-presenters
Source: https://github.com/sandeepmvl/rails-skills/tree/main/skills/34-form-objects-query-objects-presenters
Command: npx skills add https://github.com/sandeepmvl/rails-skills --skill form-objects-query-objects-presenters

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the frequent issue of bloated Rails models, misplaced multi-model form logic, unreadable complex queries, and view files cluttered with procedural formatting code that AI coding agents often misplace or over-extract.

Core Features & Use Cases

  • Form Objects: Handle multi-model form submissions (e.g., signup flows that create User, Account, and Subscription records) and non-ActiveRecord validations without polluting model classes.
  • Query Objects: Encapsulate complex, reusable ActiveRecord queries with 10+ lines of chained scopes, filters, and sorting logic for consistent reuse across controllers.
  • Presenters / Decorators: Move view-specific formatting and display logic out of models and views to keep both clean, testable, and focused on their core responsibilities.
  • Use Case: If your Rails app has a signup flow spanning 3 models, a user search with 6 filter options, and user profile views with 80 lines of conditional formatting, this Skill guides you to apply the right pattern for each scenario without over-engineering.

Quick Start

Ask your AI coding agent to refactor your multi-model signup form into a form object using ActiveModel::Model with transaction wrapping and custom validations, extract your complex filtered user search into a reusable query object, and move all user view formatting logic into a dedicated presenter class to eliminate bloat across your Rails codebase.

Frequently Asked Questions about form-objects-query-objects-presenters

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

FAQPage Schema
How do I handle multi-model form submissions in Rails without bloating models?

Multi-model form submissions in Rails are handled using form objects built with ActiveModel::Model to encapsulate transaction wrapping and custom validations, keeping User, Account, and Subscription creation logic out of core ActiveRecord models.

What is the best way to organize complex ActiveRecord queries with multiple filters?

Complex ActiveRecord queries with multiple filters and sorting logic are best organized using composable query objects, encapsulating 10+ lines of chained scopes into reusable classes for consistent controller access.

How do I remove procedural formatting code from Rails views?

Procedural formatting code is removed from Rails views by extracting it into lightweight presenter classes, keeping both views and models clean, testable, and focused on their core responsibilities.

When should I use form objects versus presenters in Ruby on Rails?

Form objects in Ruby on Rails are used for multi-model form submissions and non-ActiveRecord validations, while presenters are used exclusively for view-specific display logic and formatting.

Do I need external Rails gems to implement query objects and presenters?

External Rails gems are not needed to implement query objects and presenters; plain ActiveModel::Model and lightweight classes align with senior Rails conventions without relying on heavy dependencies unless explicitly justified.

Why does my Rails model have too much logic for user signup flows?

Rails models accumulate too much logic for user signup flows when multi-model creation, validations, and callbacks are placed directly in ActiveRecord classes instead of being extracted into dedicated form objects.