AGENT SKILL

测试驱动开发工作流

tdd-workflow

测试驱动开发(TDD)工作流。

License 许可
MIT
最近更新
2026-11-09
Stars
★ 344
Forks
7

01 前言 Front Matter

name
rails-upgrade-3-to-4
description
Upgrade a Ruby on Rails app from 3.x to 4.x — strong parameters replacing attr_accessible / attr_protected, the asset pipeline overhaul, the Turbolinks arrival, Ruby 2.0+ requirement, Bundler-style routes file, the version hop sequence. Use when upgrading legacy Rails 3 apps, the user mentions attr_accessible, Turbolinks, protected_attributes gem, asset pipeline, or asks how to escape Rails 3.

02 资源文件 1

03 SKILL.md 正文

Rails 3 → 4 Upgrade

Legacy upgrade. Rails 3.2 is past EOL (Rails 3 LTS exists but is paid). The 3.2 → 4.0 hop is API-breaking; budget for a real project, not a weekend.

The opinion

Dual-boot with next_rails. Hop 3.2 → 4.0 → 4.1 → 4.2. Ruby 2.0+ required for 4.0; Ruby 2.2.2+ for 4.2. Use the protected_attributes gem as a temporary bridge from attr_accessible to strong parameters.

The hop sequence

3.2 → 4.0 → 4.1 → 4.2

Core patterns

Pattern 1: 3.2 → 4.0

Mandatory:

  • Ruby 2.0+.
  • Switch from attr_accessible / attr_protected to strong parameters (or stay on protected_attributes gem as a bridge).
  • New asset pipeline; old Sprockets behavior changed.
  • Turbolinks ships (can disable if breaking the app).

attr_accessible removal:

# Rails 3 model
class User < ActiveRecord::Base
  attr_accessible :name, :email
end

# Rails 4 — two paths

# Path A: use the `protected_attributes` gem (keeps old API; quick win for legacy)
gem "protected_attributes_continued"  # community-maintained for 4+

# Path B: migrate to strong parameters (the long-term path)
# Remove attr_accessible from model.
# In controllers:
def user_params
  params.require(:user).permit(:name, :email)
end

Turbolinks:

# Gemfile
gem "turbolinks"

# JS that depends on $(document).ready needs to listen for "page:load" too
$(document).on('page:load ready', function() { ... })

Most Rails 3 apps with custom JS break under Turbolinks. Disable per-link with data-no-turbolink while you migrate.

Pattern 2: 4.0 → 4.1

Spring (preloader) arrives. Configuration changes:

  • secrets.yml replaces config/initializers/secret_token.rb.
  • Mailer previews (Action Mailer Preview) ship.

Pattern 3: 4.1 → 4.2

Active Job arrives — the abstraction over Sidekiq / DelayedJob / etc. Migrate background jobs:

# Rails 4.1 (Sidekiq worker)
class HardWorker
  include Sidekiq::Worker
  def perform(name); end
end

# Rails 4.2 (Active Job)
class HardWorkerJob < ActiveJob::Base
  queue_as :default
  def perform(name); end
end

Adapter is configured globally; the same job class works with Sidekiq / DelayedJob / SQS / etc.

Pattern 4: Gem audit

Rails 3 era gems often have no 4.x version. Audit:

bundle outdated
bundle update --major-version-only
# Compare each gem against its 4.x compat docs

Common replacements:

  • state_machine → aasm or state_machines-activerecord.
  • paperclip → Active Storage (or shrine).
  • cancan → cancancan (community fork).
  • inherited_resources → kept but mature; replace if you can.

Common mistakes to refuse

  • Don't ditch attr_accessible for strong_parameters in the same PR as the version bump. Use protected_attributes_continued first.
  • Don't enable Turbolinks if your JS doesn't handle it.
  • Don't skip 4.1 (Active Job arrives; migrating workers is easier here).

See also

  • rails-upgrade-4-to-5 — next hop
  • solid-queue-and-sidekiq — Active Job (introduced in 4.2)

Sources

04 同仓库更多 Skills

mrwogu
mrwogu/promptscript

PromptScript 脚本编写与排查

promptscript

PromptScript 语言专家,用于读取、编写、修改和排查 .prs 文件。适用于处理 PromptScript 语法、创建或编辑 .prs 文件、添加 @identity、@standards、@restrictions、@shortcuts、@skills 或 @agents 等块、配置 promptscript.yaml、解决编译错误、理解继承(@inherit)、组合(@use、@extend、@override)、上下文 @header 元数据,或将 AI 指令迁移到 PromptScript。当用户询问 50 个内置编码智能体编译目标(包括 GitHub Copilot、Claude Code、Cursor、Antigravity、Factory AI 以及基于 AGENTS.md 的平台),或询问用于应用提示词的 bundle 和 prompt-text 目标时,也适用此技能。

AI 工程师提示词工程与优化
★ 344
mrwogu
mrwogu/promptscript

基础专家技能

expert

基础专家技能。

AI 工程师AI系统核心与身份配置
★ 344
mrwogu
mrwogu/promptscript

Alpha 技能

alpha

Alpha 技能

普通用户示例与演示技能
★ 344
mrwogu
mrwogu/promptscript

PDF 文件处理

pdf-processing

提取 PDF 文本、填写表单、合并文件。用于处理 PDF 时。

普通用户文档处理
★ 344
mrwogu
mrwogu/promptscript

React 组件编写规范

react-component-patterns

在此代码库中编写 React 组件的约定。

软件开发工程师前端开发与界面实现
★ 344
mrwogu
mrwogu/promptscript

应用部署发布

deploy-app

将应用部署到预发布(staging)或生产环境。用于部署代码,或当用户提到部署、发布或环境时。

SRE 工程师部署与发布管理
★ 344