rails-presenter

Generate Rails presenter objects using SimpleDelegator with a TDD workflow.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill streamlines the process of creating presenter objects in Rails applications, ensuring cleaner view logic and better test coverage through a Test-Driven Development (TDD) approach.

Core Features & Use Cases

  • TDD Workflow: Guides users through writing specs before implementation for presenters.
  • View Logic Extraction: Helps move formatting and display logic out of models and controllers.
  • Use Case: When you need to format dates, display status badges with specific styling, or present currency values in a user-friendly way within your Rails views, this Skill provides a structured method to create dedicated presenter classes.

Quick Start

Write a failing spec for your new presenter in spec/presenters/ and then implement the presenter in app/presenters/.

Frequently Asked Questions about rails-presenter

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

FAQPage Schema
How do I extract view formatting logic from Rails models and controllers?

Rails presenters using the SimpleDelegator pattern move display logic out of models and controllers into dedicated objects. This extraction isolates formatting concerns like dates and currency, ensuring your models and controllers remain maintainable and cleanly structured.

How do I use TDD to build a Rails presenter for formatting dates and currency?

To build a Rails presenter with TDD, you first write a failing spec in the spec/presenters/ directory for your desired formatting output. You then implement the presenter class in app/presenters/ until the spec passes, ensuring testable and maintainable view logic.

What is the SimpleDelegator pattern for Rails presenters?

The SimpleDelegator pattern for Rails presenters involves wrapping a model object within a delegator class. This allows you to add view-specific formatting methods, such as status badges or currency display, without polluting the underlying model with presentation logic.

Can Rails presenters handle internationalization and HTML-safe output for status badges?

Yes, Rails presenters can handle internationalization and generate HTML-safe output for display elements like status badges. The presenter encapsulates this formatting logic, ensuring that translated strings and HTML tags are safely rendered within your application views.

What is the best way to organize view-specific formatting logic in a Rails application?

The best way to organize view-specific formatting logic in Rails is using presenters built with a Test-Driven Development workflow. By placing these classes in app/presenters/ and their specs in spec/presenters/, you maintain clear separation of concerns and high test coverage for display code.

Do I need any special dependencies to generate Rails presenters with TDD?

You do not need any special dependencies to generate Rails presenters with TDD. The workflow relies on standard Ruby SimpleDelegator patterns and native Rails directory structures like app/presenters/ and spec/presenters/ to implement and test the formatting logic.