Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

form-object-patterns形成对象模式

Agent Skill

form-object-patterns 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

474

周安装

19

GitHub Stars

520

下载量

154
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:form-object-patterns(形成对象模式)
来源仓库:https://github.com/thibautbaissac/rails_ai_agents
仓库路径:skills/form-object-patterns
安装命令:
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill form-object-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill form-object-patterns

简介

form-object-patterns 用于查找、检索和筛选相关信息。

  • 它适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果时使用。
  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装命令:npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill form-object-patterns
  • 来源仓库:https://github.com/thibautbaissac/rails_ai_agents

SKILL.md

Form Object Patterns for Rails 8

Overview

Form objects encapsulate complex form logic:

  • Multi-model forms (user + profile + address)
  • Search/filter forms (non-persisted)
  • Wizard/multi-step forms
  • Virtual attributes with validation
  • Decoupled from ActiveRecord models

When to Use Form Objects

ScenarioUse Form Object?
Single model CRUDNo (use model)
Multi-model creationYes
Complex validations across modelsYes
Search/filter formsYes
Wizard/multi-step formsYes
API params transformationYes
Contact forms (no persistence)Yes

TDD Workflow

Form Object Progress:
- [ ] Step 1: Define form requirements
- [ ] Step 2: Write form object spec (RED)
- [ ] Step 3: Run spec (fails)
- [ ] Step 4: Create form object
- [ ] Step 5: Run spec (GREEN)
- [ ] Step 6: Wire up controller
- [ ] Step 7: Create view form

Project Structure

app/
├── forms/
│   ├── application_form.rb       # Base class
│   ├── registration_form.rb      # Multi-model
│   ├── search_form.rb            # Non-persisted
│   └── wizard/
│       ├── base_form.rb
│       ├── step_one_form.rb
│       └── step_two_form.rb
spec/forms/
├── registration_form_spec.rb
└── search_form_spec.rb

Base Form Class

# app/forms/application_form.rb
class ApplicationForm
  include ActiveModel::Model
  include ActiveModel::Attributes
  include ActiveModel::Validations

  def self.model_name
    ActiveModel::Name.new(self, nil, name.chomp("Form"))
  end

  def persisted?
    false
  end

  def save
    return false unless valid?
    persist!
    true
  rescue ActiveRecord::RecordInvalid => e
    errors.add(:base, e.message)
    false
  end

  private

  def persist!
    raise NotImplementedError
  end
end

Patterns

Four patterns are implemented with full TDD cycles. See patterns.md:

  • Pattern 1: Multi-Model Registration Form — creates a User and Account in a transaction; validates email uniqueness and password confirmation; exposes form.user and form.account after save. Includes spec (RED) and implementation (GREEN).
  • Pattern 2: Search/Filter Form — non-persisted form with query, type, status, and date range filters applied as chainable scopes; exposes results and any_filters? helpers for views. Includes spec and implementation.
  • Pattern 3: Wizard/Multi-Step FormWizard::BaseForm provides next_step, previous_step, first_step?, last_step?, and progress_percentage; each step subclass declares its own attributes and validations.
  • Pattern 4: Contact Form (No Persistence) — overrides #save directly (no persist!); dispatches via deliver_later without writing to the database.

Controller and View Integration

See controller-and-views.md for:

  • Standard controller with allow_unauthenticated_access, #new / #create, render:new, status::unprocessable_entity on failure
  • form_with model: @form views with error display
  • Search form partial with selects, date fields, and a "Clear" link when filters are active

Key conventions:

  • Use form_with model: @form, url: explicit_path — the form object is not an ActiveRecord model
  • Permit params with params.require(:model_name).permit(...) using the snake-case class name without "Form"
  • Always render:new, status::unprocessable_entity on failure so Turbo handles the response

Checklist

  • Spec written first (RED)
  • Extends ApplicationForm or includes ActiveModel::Model
  • Attributes declared with types
  • Validations defined
  • #save method with transaction (if multi-model)
  • Controller uses form object
  • View uses form_with model: @form
  • Error handling in place
  • All specs GREEN

References

  • patterns.md — Full TDD implementations of all 4 patterns: multi-model registration, search/filter, wizard/multi-step, and contact form
  • controller-and-views.md — Controller with unauthenticated access, registration form view, and search form partial

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.92%
按下载量换算48

OpenCode

22.12%
按下载量换算34

Codex

17.96%
按下载量换算28

Antigravity

13.86%
按下载量换算21

windsurf

7.64%
按下载量换算12

trae

3.91%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills