Skip to content

ombulabs/claude-code_rails-upgrade-skill / rails-upgrade

rails-upgrade

Verified

Analyzes Rails applications and generates comprehensive upgrade reports with breaking changes, deprecations, and step-by-step migration guides for Rails 2.3 through 8.1. Use when upgrading Rails applications, planning multi-hop upgrades, querying version-specific changes, or answering what stands between the app and the next Rails version. Based on FastRuby.io methodology and "The Complete Guide to Upgrade Rails" ebook.

FileKindSize
SKILL.mdskill md11.0 KB
detection-scripts/gem_limits.rbscript6.0 KB
detection-scripts/hop.rbscript2.2 KB
detection-scripts/patterns/rails-40-patterns.expectations.ymlconfig43.8 KB
detection-scripts/patterns/rails-40-patterns.ymlconfig96.5 KB
detection-scripts/patterns/rails-41-patterns.expectations.ymlconfig25.6 KB
detection-scripts/patterns/rails-41-patterns.ymlconfig59.8 KB
detection-scripts/patterns/rails-42-patterns.expectations.ymlconfig27.5 KB
detection-scripts/patterns/rails-42-patterns.ymlconfig48.7 KB
detection-scripts/patterns/rails-50-patterns.expectations.ymlconfig1.9 KB
detection-scripts/patterns/rails-50-patterns.ymlconfig8.1 KB
detection-scripts/patterns/rails-51-patterns.expectations.ymlconfig4.2 KB
detection-scripts/patterns/rails-51-patterns.ymlconfig15.0 KB
detection-scripts/patterns/rails-52-patterns.expectations.ymlconfig5.0 KB
detection-scripts/patterns/rails-52-patterns.ymlconfig14.7 KB
detection-scripts/patterns/rails-60-patterns.expectations.ymlconfig1007 B
detection-scripts/patterns/rails-60-patterns.ymlconfig14.2 KB
detection-scripts/patterns/rails-70-patterns.expectations.ymlconfig4.0 KB
detection-scripts/patterns/rails-70-patterns.ymlconfig11.2 KB
detection-scripts/patterns/rails-71-patterns.expectations.ymlconfig3.1 KB
detection-scripts/patterns/rails-71-patterns.ymlconfig9.5 KB
detection-scripts/patterns/rails-72-patterns.expectations.ymlconfig1.2 KB
detection-scripts/patterns/rails-72-patterns.ymlconfig6.1 KB
detection-scripts/patterns/rails-80-patterns.expectations.ymlconfig6.6 KB
detection-scripts/patterns/rails-80-patterns.ymlconfig21.2 KB
detection-scripts/patterns/rails-81-patterns.expectations.ymlconfig4.3 KB
detection-scripts/patterns/rails-81-patterns.ymlconfig13.2 KB
detection-scripts/scan_patterns.rbscript42.8 KB
examples/multi-hop-upgrade.mdmarkdown18.9 KB
examples/simple-upgrade.mdmarkdown4.0 KB
references/breaking-changes-by-version-reference.mdmarkdown3.9 KB
references/deprecation-warnings-reference.mdmarkdown10.7 KB
references/gem-compatibility-reference.mdmarkdown8.2 KB
references/js-compressor-sprockets-mismatch-reference.mdmarkdown4.7 KB
references/multi-hop-strategy-reference.mdmarkdown8.8 KB
references/next-hop-readiness-reference.mdmarkdown2.1 KB
references/no-test-suite-smoke-reference.mdmarkdown4.7 KB
references/request-patterns-reference.mdmarkdown3.7 KB
references/sequential-strategy-reference.mdmarkdown2.1 KB
references/staying-current-reference.mdmarkdown7.8 KB
references/testing-checklist-reference.mdmarkdown6.3 KB
templates/app-update-preview-template.mdmarkdown4.3 KB
templates/upgrade-report-template.mdmarkdown10.2 KB
version-guides/upgrade-3.2-to-4.0.mdmarkdown68.0 KB
version-guides/upgrade-4.0-to-4.1.mdmarkdown66.7 KB
version-guides/upgrade-4.1-to-4.2.mdmarkdown60.7 KB
version-guides/upgrade-4.2-to-5.0.mdmarkdown9.7 KB
version-guides/upgrade-5.0-to-5.1.mdmarkdown19.1 KB
version-guides/upgrade-5.1-to-5.2.mdmarkdown17.7 KB
version-guides/upgrade-5.2-to-6.0.mdmarkdown6.4 KB
version-guides/upgrade-6.0-to-6.1.mdmarkdown6.8 KB
version-guides/upgrade-6.1-to-7.0.mdmarkdown14.7 KB
version-guides/upgrade-7.0-to-7.1.mdmarkdown13.2 KB
version-guides/upgrade-7.1-to-7.2.mdmarkdown11.2 KB
version-guides/upgrade-7.2-to-8.0.mdmarkdown23.1 KB
version-guides/upgrade-8.0-to-8.1.mdmarkdown14.0 KB
workflows/00-verify-latest-patch-workflow.mdmarkdown1.7 KB
workflows/01-run-test-suite-workflow.mdmarkdown12.7 KB
workflows/02-resolve-deprecation-warnings-workflow.mdmarkdown6.3 KB
workflows/03-validate-upgrade-path-workflow.mdmarkdown1.8 KB
workflows/04-setup-next-rails-workflow.mdmarkdown1.5 KB
workflows/05-detect-breaking-changes-workflow.mdmarkdown20.0 KB
workflows/06-check-gem-compatibility-workflow.mdmarkdown11.1 KB
workflows/07-boot-smoke-test-workflow.mdmarkdown7.3 KB
workflows/08-generate-upgrade-report-workflow.mdmarkdown12.7 KB
workflows/09-generate-app-update-preview-workflow.mdmarkdown7.3 KB
workflows/10-implement-and-upgrade-workflow.mdmarkdown2.5 KB
workflows/11-sync-ci-workflow.mdmarkdown8.6 KB
workflows/12-align-load-defaults-workflow.mdmarkdown952 B
workflows/13-mention-cleanup-workflow.mdmarkdown1.3 KB

version-guides/upgrade-6.0-to-6.1.md

View on GitHub
# Rails 6.0 → 6.1 Upgrade Guide

**Ruby Requirement:** 2.5.0+ (2.7+ recommended)

**Based on "The Complete Guide to Upgrade Rails" by FastRuby.io (OmbuLabs)**

---

## Overview

Rails 6.1 introduces:
- **Horizontal database sharding** support
- **Strict loading** to prevent N+1 queries
- **Per-database connection switching**
- **Destroy associations async**
- **Error objects** in Active Model

---

## Breaking Changes

### ðŸ”ī HIGH PRIORITY

#### update_attributes Removed

**What Changed:**
`update_attributes` and `update_attributes!`, deprecated aliases of `update` and `update!` in 6.0, are removed. Every call raises `NoMethodError`, including calls through `send(:update_attributes, ...)`. There is no patterns file for this hop, so search for them by hand: `grep -rnw update_attributes app lib spec test`, which also finds the `!` form.

**Detection Pattern:**
```ruby
user.update_attributes(name: 'New Name')
user.update_attributes!(name: 'New Name')
```

**Fix:**
```ruby
# BEFORE
user.update_attributes(name: 'New Name')

# AFTER
user.update(name: 'New Name')
```

`update` exists on 6.0 as well, so the rewrite can land before the version bump with no `NextRails.next?` branch.

---

#### config_for Returns HashWithIndifferentAccess

**What Changed:**
`Rails.application.config_for` now returns `ActiveSupport::HashWithIndifferentAccess` instead of `Hash`.

**Detection Pattern:**
```ruby
config = Rails.application.config_for(:some_config)
config.keys.first.class  # Was String, now can be accessed as symbol
```

**Fix:**
This is usually transparent, but if you're checking key types explicitly:
```ruby
# BEFORE (may break)
if config.keys.include?("database")

# AFTER (works with both)
if config.key?(:database) || config.key?("database")
```

---

#### respond_to#any Content-Type Change

**What Changed:**
`respond_to#any` now returns `text/html` Content-Type instead of `*/*`.

**Detection Pattern:**
```ruby
respond_to do |format|
  format.any { render json: @data }
end
```

**Fix:**
If you need specific Content-Type, use explicit format:
```ruby
# BEFORE
respond_to do |format|
  format.any { render json: @data }
end

# AFTER (explicit JSON)
respond_to do |format|
  format.json { render json: @data }
  format.any { render json: @data, content_type: 'application/json' }
end
```

---

#### HTTPS Redirects Use 308 Status

**What Changed:**
`config.force_ssl` now uses HTTP status 308 instead of 301 for redirects.

**Impact:**
308 preserves the HTTP method (POST stays POST). This is usually correct behavior, but may affect some clients.

**Fix:**
If you need the old 301 behavior:
```ruby
# config/environments/production.rb
config.ssl_options = { redirect: { status: 301 } }
```

---

#### ActiveSupport::Callbacks Default Changed

**What Changed:**
`:unless` and `:if` callbacks now default to `:before` rather than `:after`.

**Detection Pattern:**
```ruby
set_callback :save, :around, :my_callback, if: :condition
```

**Fix:**
Be explicit about callback type:
```ruby
set_callback :save, :around, :my_callback, if: :condition, prepend: true
```

---

### ðŸŸĄ MEDIUM PRIORITY

#### ActiveRecord::Base.allow_unsafe_raw_sql Removed

**What Changed:**
The `allow_unsafe_raw_sql` configuration has been removed.

**Detection Pattern:**
```ruby
ActiveRecord::Base.allow_unsafe_raw_sql = :enabled
```

**Fix:**
Remove the configuration. Use `Arel.sql()` for raw SQL:
```ruby
# BEFORE
Model.order("FIELD(id, #{ids.join(',')})")

# AFTER
Model.order(Arel.sql("FIELD(id, #{ids.join(',')})"))
```

---

#### ActiveModel::Errors API Change

**What Changed:**
`ActiveModel::Errors` now returns `Error` objects instead of strings.

**Detection Pattern:**
```ruby
user.errors[:email].first  # Was String
user.errors.full_messages  # Still works
```

**Fix:**
```ruby
# BEFORE
error_string = user.errors[:email].first

# AFTER
error = user.errors.where(:email).first
error.message  # Get the message
error.full_message  # Get full message with attribute name
```

---

#### find_or_create_by Behavior Change

**What Changed:**
`find_or_create_by` now handles race conditions better, but behavior changed slightly.

**Detection Pattern:**
```ruby
User.find_or_create_by(email: email)
```

**Fix:**
No changes needed for typical usage. If you relied on specific exception behavior, test thoroughly.

---

## New Features

### Horizontal Database Sharding

```ruby
# database.yml
production:
  primary:
    database: my_primary
  primary_shard_one:
    database: my_shard_one
```

### Strict Loading (Prevent N+1)

```ruby
class User < ApplicationRecord
  has_many :posts, strict_loading: true
end

# Or at query time
User.strict_loading.includes(:posts).first
```

### Destroy Associations Async

```ruby
class User < ApplicationRecord
  has_many :posts, dependent: :destroy_async
end
```

---

## Migration Steps

### Phase 1: Preparation
```bash
git checkout -b rails-61-upgrade

# Set up dual-boot
gem install next_rails
next_rails --init
```

### Phase 2: Gemfile Updates
```ruby
# Gemfile
if next?
  gem 'rails', '~> 6.1.0'
else
  gem 'rails', '~> 6.0.0'
end
```

### Phase 3: Fix Breaking Changes
1. Replace `update_attributes` / `update_attributes!` with `update` / `update!`
2. Review `config_for` usage
3. Check `respond_to#any` blocks
4. Test SSL redirects if critical
5. Update `ActiveModel::Errors` usage

### Phase 4: Configuration
```bash
rails app:update
```

Update `config/application.rb`:
```ruby
config.load_defaults 6.1
```

### Phase 5: Testing
- Run full test suite
- Test forms with validations
- Test API responses Content-Type
- Verify SSL redirects work correctly

---

## Configuration Migration Checklist

- [ ] Review `config_for` usage for hash access patterns
- [ ] Check `respond_to#any` blocks for Content-Type expectations
- [ ] Test SSL redirect behavior
- [ ] Update `ActiveModel::Errors` usage if accessing errors directly
- [ ] Update `load_defaults` to 6.1

---

## Common Issues — Quick Reference

Error → section lookup for the most common errors encountered during this upgrade:

| Error | See |
|-------|-----|
| `NoMethodError: undefined method 'update_attributes'` | "update_attributes Removed": replace with `update` |
| API client receives `text/html` instead of `application/json` | "respond_to#any Content-Type Change" — `format.json { render json: ... }` |
| SSL redirect loops on POST requests | "HTTPS Redirects Use 308 Status" — `config.ssl_options = { redirect: { status: 301 } }` if the proxy cannot handle 308 |
| `NoMethodError: undefined method 'include?' for #<ActiveModel::Error>` | "ActiveModel::Errors API Change" — `errors.where(:email).map(&:message)` |

---

## Resources

- [Rails 6.1 Release Notes](https://guides.rubyonrails.org/6_1_release_notes.html)
- [RailsDiff 6.0 to 6.1](http://railsdiff.org/6.0.6/6.1.0)
- [Horizontal Sharding Guide](https://guides.rubyonrails.org/active_record_multiple_databases.html)
planning-and-task-breakdownaddyosmani/agent-skillsBreaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
screenpipethedotmack/claude-memSearch screen and audio history recorded by Screenpipe and optionally save selected context into claude-mem. Use when the user asks to recall desktop activity, a meeting, or something seen in another app through Screenpipe.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
contact-widgetnexu-io/open-designSelf-contained floating chat widget with welcome screen, social links, meeting button, and message input. Single HTML file, zero dependencies.Stars: 108kUpdated Claude CodeCodexVerifiedInstall
meeting-notesnexu-io/open-designMeeting notes page — title bar with attendees, agenda checklist, decisions block, action items table with owners + dates, and a "next meeting" footer. Use when the brief mentions "meeting notes", "minutes", "1:1 notes", "all-hands recap", or "侚čŪŪįšŠč́".Stars: 108kUpdated Claude CodeCodexVerifiedInstall