ombulabs/claude-code_rails-upgrade-skill / rails-upgrade
rails-upgrade
VerifiedAnalyzes 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.
detection-scripts/patterns/rails-50-patterns.yml
View on GitHubversion: "5.0"
description: "Breaking change patterns for Rails 4.2 → 5.0 upgrade"
upgrade_findings:
high_priority:
- name: "Ruby version below 2.2.2"
kind: "breaking"
pattern: "^\\s*(?:ruby\\s*\\(?\\s*[\"'](?:=\\s*|~>\\s*(?=\\d+\\.\\d+\\.\\d))?|ruby-|ruby\\s+)?(?:1\\.\\d+|2\\.[01])(?:\\.\\d+)*(?![\\d.])|^\\s*(?:ruby\\s*\\(?\\s*[\"'](?:=\\s*)?|ruby-|ruby\\s+)?2\\.2\\.[01](?![\\d.])|^\\s*ruby\\s*\\(?\\s*[\"']~>\\s*1\\.\\d+(?![\\d.])"
exclude: ""
search_paths:
- "Gemfile"
- ".ruby-version"
- ".tool-versions"
explanation: "Rails 5.0 requires Ruby 2.2.2 or newer. Flags a Ruby below 2.2.2 in .ruby-version or .tool-versions, and a Gemfile `ruby` line that rules it out (an exact version, or a `~>` whose upper bound is below 2.2.2); a requirement that still allows 2.2.2, such as `>=`, is not flagged"
fix: "Upgrade Ruby to 2.2.2+ (2.3+ recommended)"
variable_name: "RUBY_VERSION"
- name: "Models inheriting from ActiveRecord::Base"
kind: "migration"
pattern: "class\\s+\\w+\\s*<\\s*ActiveRecord::Base"
exclude: "ApplicationRecord"
search_paths:
- "app/models/"
explanation: "Rails 5.0 introduces ApplicationRecord as the base class for all models"
fix: "Create app/models/application_record.rb and change all models to inherit from ApplicationRecord"
variable_name: "ACTIVERECORD_BASE"
- name: "belongs_to without optional: true"
kind: "migration"
pattern: "belongs_to\\s+:\\w+"
exclude: "optional:"
search_paths:
- "app/models/"
explanation: "Rails 5.0 makes belongs_to required by default. Review each match to determine if the association can be nil"
fix: "Add optional: true only to belongs_to associations that can legitimately be nil. Leave required ones as-is"
variable_name: "BELONGS_TO_REQUIRED"
- name: "protected_attributes gem"
kind: "breaking"
pattern: "gem.*['\"]protected_attributes['\"]"
exclude: ""
search_paths:
- "Gemfile"
explanation: "The protected_attributes gem is not compatible with Rails 5.0. You must migrate to Strong Parameters"
fix: "Remove protected_attributes gem, remove attr_accessible from models, add *_params methods to controllers"
variable_name: "PROTECTED_ATTRIBUTES"
- name: "attr_accessible in models"
kind: "breaking"
pattern: "attr_accessible"
exclude: ""
search_paths:
- "app/models/"
explanation: "attr_accessible is removed in Rails 5.0. Use Strong Parameters in controllers instead"
fix: "Remove attr_accessible from models and add *_params methods to controllers"
variable_name: "ATTR_ACCESSIBLE"
- name: "Parameters used as hash"
kind: "breaking"
pattern: "params(\\[.*\\])?\\.(slice|except|merge|symbolize_keys|to_hash)\\b"
exclude: ""
search_paths:
- "app/controllers/"
- "app/"
explanation: "params is now ActionController::Parameters, not HashWithIndifferentAccess. Hash methods may not work"
fix: "Call .permit and .to_h before using hash methods on params"
variable_name: "PARAMS_AS_HASH"
medium_priority:
- name: "Callback returning false to halt"
kind: "deprecation"
pattern: "\\breturn\\s+false\\b|^[ \\t]*false(?:[ \\t]+(?:if|unless)\\b[^\\n]*)?(?=[ \\t]*(#[^\\n]*)?\\n\\s*(end|else|elsif|when|rescue|ensure)\\b)|\\bbefore_(save|create|update|destroy|validation)\\b[^\\n{]*\\{[^}\\n]*\\bfalse\\b"
exclude: "\\A\\s*#"
search_paths:
- "app/models/"
explanation: "Rails 5.0 stops halting an Active Record or Active Model callback chain on a `false` return: with `ActiveSupport.halt_callback_chains_on_return_false = false` (the 5.0 default for new apps, and the only behavior from 5.1 on, where the setting is ignored) the save or destroy goes ahead, and on the upgrade setting of `true` it still halts but warns. Only a before_* callback that yields `false` on purpose needs a fix. The pattern flags the three shapes that yield it: `return false`, a bare `false`, alone or with a trailing `if`/`unless`, ending a method or a branch (the line before `end`, `else`, `elsif`, `when`, `rescue` or `ensure`), and a one-line `before_* { ... false ... }` block. It cannot see a callback whose last expression merely evaluates to false (`!locked?`, `errors.add(...) && false`), so read each before_* callback's last line too. Controllers are not searched: `before_action` halted on `response_body` in 3.2 and 4.x and on `performed?` from 5.0 (AbstractController::Callbacks terminator), so a `false` return from a controller filter never stopped the action on any version. Callbacks declared on plain Active Model objects outside app/models/ are not searched either"
fix: "In a before_* callback, replace the halting `false` with `throw :abort` (`return false` becomes `throw :abort`, a bare trailing `false` becomes `throw :abort`). `throw :abort` raises UncaughtThrowError on 4.2, so on a dual-boot app branch it: `NextRails.next? ? throw(:abort) : false`. A match in a method that is not registered as a before_* callback is not a finding. A controller filter that relied on returning false never halted; make it `render` or `redirect_to` to stop the action"
variable_name: "CALLBACK_HALT"
- name: "assigns in tests"
kind: "breaking"
pattern: "assigns\\(:"
exclude: ""
search_paths:
- "test/"
- "spec/"
explanation: "assigns and assert_template are extracted to the rails-controller-testing gem in Rails 5.0"
fix: "Add gem 'rails-controller-testing' to Gemfile test group"
variable_name: "ASSIGNS_IN_TESTS"
- name: "assert_template in tests"
kind: "breaking"
pattern: "assert_template"
exclude: ""
search_paths:
- "test/"
- "spec/"
explanation: "assert_template is extracted to the rails-controller-testing gem in Rails 5.0"
fix: "Add gem 'rails-controller-testing' to Gemfile test group"
variable_name: "ASSERT_TEMPLATE"
- name: "ActionDispatch::Http::UploadedFile in tests"
kind: "migration"
pattern: "ActionDispatch::Http::UploadedFile"
exclude: ""
search_paths:
- "test/"
- "spec/"
explanation: "Use Rack::Test::UploadedFile instead of ActionDispatch::Http::UploadedFile in Rails 5.0"
fix: "Replace with Rack::Test::UploadedFile.new(file_path, content_type)"
variable_name: "UPLOAD_FILE_TEST"
- name: "redirect_to :back deprecated"
kind: "deprecation"
pattern: "redirect_to\\s+:back\\b"
exclude: ""
search_paths:
- "app/controllers/"
explanation: "Rails 5.0 deprecates redirect_to :back (emits a deprecation warning). It is removed outright in Rails 5.1, so fix all call sites now to avoid a runtime break on the next hop"
fix: "Replace with redirect_back(fallback_location: root_path). Pass any flash/notice options as keyword args: redirect_back(fallback_location: root_path, notice: 'Done!')"
variable_name: "REDIRECT_TO_BACK_DEPRECATED"
- name: "rake commands in scripts or docs"
kind: "migration"
pattern: "\\brake\\s+(db:|test|routes|assets:|secret)"
exclude: ""
search_paths:
- "bin/"
- "scripts/"
- "Rakefile"
- "lib/tasks/"
explanation: "Rails 5.0 prefers 'rails' command over 'rake' for db, test, routes, etc."
fix: "Replace 'rake' with 'rails' for db:migrate, test, routes, and other Rails commands"
variable_name: "RAKE_COMMANDS"
dependencies:
rails-controller-testing:
check: true
gem_name: "rails-controller-testing"
message: "Required if tests use assigns() or assert_template"
url: "https://github.com/rails/rails-controller-testing"
test_unit:
check: false
gem_name: "test-unit"
message: "Required if you see 'cannot load such file -- test/unit/assertions' after upgrading Ruby"
url: "https://github.com/test-unit/test-unit"
rails_upgrader:
check: false
gem_name: "rails_upgrader"
message: "Helps automate Strong Parameters migration from attr_accessible"
url: "https://github.com/fastruby/rails_upgrader"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |
| 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: 108k | Updated | Claude CodeCodex | Verified | Install |
| 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: 108k | Updated | Claude CodeCodex | Verified | Install |