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

detection-scripts/patterns/rails-42-patterns.yml

View on GitHub
version: "4.2"
description: "Breaking change patterns for Rails 4.1 → 4.2 upgrade"

upgrade_findings:
  high_priority:
    - name: "ActionMailer .deliver / .deliver! deprecated"
      kind: "deprecation"
      pattern: "\\.deliver!?\\s*(#|$)"
      exclude: ""
      search_paths:
        - "app/"
        - "lib/"
      explanation: "Rails 4.2 deprecates .deliver and .deliver! in favor of .deliver_now / .deliver_now! (sync) and .deliver_later (async via ActiveJob)"
      fix: "Replace .deliver with .deliver_now, and .deliver! with .deliver_now! (bang-preserving). Use .deliver_later for async delivery via ActiveJob"
      variable_name: "MAILER_DELIVER"

    - name: "respond_with usage"
      kind: "breaking"
      pattern: "\\brespond_with\\b"
      exclude: ""
      search_paths:
        - "app/controllers/"
      explanation: "respond_with and class-level respond_to were extracted from Rails core into the responders gem in Rails 4.2"
      fix: "Add gem 'responders', '~> 2.0' to your Gemfile. No code changes needed."
      variable_name: "RESPOND_WITH"

    - name: "Class-level respond_to declaration"
      kind: "breaking"
      pattern: "^\\s*respond_to\\s+:"
      exclude: ""
      search_paths:
        - "app/controllers/"
      explanation: "Class-level respond_to was extracted to the responders gem. Action-level respond_to do |format| blocks are unaffected"
      fix: "Add gem 'responders', '~> 2.0' to your Gemfile"
      variable_name: "CLASS_RESPOND_TO"

    - name: "Verify raise_in_transactional_callbacks is configured"
      kind: "deprecation"
      pattern: "class\\s+\\w+\\s*<\\s*Rails::Application"
      exclude: ""
      unless_file_matches: "^[ \\t]*config\\.active_record\\.raise_in_transactional_callbacks[ \\t]*=[ \\t]*true[ \\t]+if[ \\t]+NextRails\\.next\\?"
      search_paths:
        - "config/application.rb"
      explanation: "FILE MARKER (manual review required): Rails 4.2 still rescues and logs exceptions raised in after_commit/after_rollback callbacks, and while config.active_record.raise_in_transactional_callbacks is false it emits a deprecation warning for every after_commit/after_rollback declaration as each model class loads. Rails 5.0 always raises. Setting it to true opts in to the 5.0 behavior: callback exceptions then propagate out of save/transaction, which can fail tests or requests that passed before. The setter does not exist on Rails 4.1 and the active_record.set_configs initializer sends every config.active_record key to ActiveRecord::Base, so an unconditional line raises NoMethodError on the 4.1 side of a dual-boot app as soon as ActiveRecord::Base loads (at boot with eager_load, at the first model reference otherwise). A direct ActiveRecord::Base.raise_in_transactional_callbacks = true in an initializer fails the same way. Grep cannot detect absence of a setting, so this pattern flags config/application.rb itself. Open it and check the setting is present and gated. scan_patterns.rb skips the file only when an uncommented line sets the option to true behind `if NextRails.next?` (an unconditional line or another condition is still flagged, since on 4.1 that line is the bug); it cannot see the option set in an initializer or an environment file, so check there before adding it"
      fix: "While dual booting, add `config.active_record.raise_in_transactional_callbacks = true if NextRails.next?` to config/application.rb (never unconditionally: Rails 4.1 raises NoMethodError when ActiveRecord::Base loads; gate a direct ActiveRecord::Base setter in an initializer the same way), then run the suite on 4.2 and fix any after_commit/after_rollback exception that now propagates. If the line is already there without the gate, add the gate. Drop the `if NextRails.next?` once the app runs only on 4.2. Without next_rails, add the line unconditionally in the commit that moves to 4.2"
      variable_name: "TRANSACTIONAL_CALLBACKS"

    - name: "RSpec 2.x in Gemfile"
      kind: "breaking"
      pattern: "rspec-rails.*['\"\\(][~><=\\s]*2\\."
      exclude: ""
      search_paths:
        - "Gemfile"
        - "Gemfile.lock"
      explanation: "Rails 4.2 does not support RSpec 2. You must upgrade to RSpec 3 (use 2.99 as an intermediate step to surface deprecations). Matches ~>, >=, >, <=, bare versions, and locked (2.x.y) versions"
      fix: "Upgrade to rspec-rails 2.99 first, fix deprecations, then upgrade to rspec-rails 3.x. Consider Transpec for automation"
      variable_name: "RSPEC_2"

    - name: "assert_tag / TagAssertions"
      kind: "deprecation"
      pattern: "\\bassert_tag\\b"
      exclude: ""
      search_paths:
        - "test/"
        - "spec/"
      explanation: "assert_tag and the TagAssertions module are deprecated in Rails 4.2. Use assert_select from SelectorAssertions (now in the rails-dom-testing gem)"
      fix: "Replace assert_tag with assert_select equivalents"
      variable_name: "ASSERT_TAG"

    - name: "ActiveJob usage requires queue adapter"
      kind: "migration"
      pattern: "\\.deliver_later\\b|<\\s*ActiveJob::Base\\b"
      exclude: ""
      search_paths:
        - "app/"
        - "lib/"
      explanation: "Rails 4.2 introduces ActiveJob. Any use of deliver_later or a class inheriting from ActiveJob::Base requires a configured queue adapter. The default in 4.2 is :inline (runs jobs synchronously in-process), which is rarely what production wants"
      fix: "Set config.active_job.queue_adapter = :sidekiq (or :resque, :delayed_job, :que, etc.) in config/application.rb or per-environment, and ensure the adapter gem is in the Gemfile. For dev/test without a backend, :inline or :async is acceptable"
      variable_name: "ACTIVE_JOB_ADAPTER"

    - name: "Patch of Mapper::Mapping#normalize_conditions! or other Mapping internals"
      kind: "breaking"
      pattern: "(?<!\\w)(?:normalize_(?:conditions|requirements)!|default_controller_and_action)(?![\\w?!])|\\bRouting::Mapper::Mapping\\b|\\b(?:module[ \\t]+(?:ActionDispatch::)?Routing(?:[ \\t]*;|[ \\t]*(?:#[^\\n]*)?\\r?\\n(?:[ \\t\\r]*(?:#[^\\n]*)?\\n)*)[ \\t]*class[ \\t]+Mapper(?:::Mapping\\b|(?:[ \\t]*;|[ \\t]*(?:#[^\\n]*)?\\r?\\n(?:[ \\t\\r]*(?:#[^\\n]*)?\\n)*)[ \\t]*class[ \\t]+Mapping\\b)|class[ \\t]+(?:::)?ActionDispatch::Routing::Mapper(?:[ \\t]*;|[ \\t]*(?:#[^\\n]*)?\\r?\\n(?:[ \\t\\r]*(?:#[^\\n]*)?\\n)*)[ \\t]*class[ \\t]+Mapping\\b)"
      exclude: ""
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
      explanation: "Rails 4.0 and 4.1 build a route's required_defaults (every option that is not a Regexp, a path segment or an ignored option) in the private ActionDispatch::Routing::Mapper::Mapping#normalize_conditions!. Apps patch it to keep custom route options (authorization metadata, for instance) out of required_defaults, so url_for(controller:, action:) without the named helper still finds the route. Rails 4.2 rewrote Mapping: normalize_conditions!, normalize_requirements! and default_controller_and_action are gone, required_defaults is built in a new private constraints(options, path_params), and normalize_defaults!, normalize_options! and normalize_path! now take arguments. A patch that aliases a removed method (alias_method, alias_method_chain) raises NameError at boot. A patch that overrides it (reopen or prepend) silently stops running, and url_for raises ActionController::UrlGenerationError again. A zero-argument override of normalize_defaults!, normalize_options! or normalize_path! raises ArgumentError when routes are drawn. Mapping#initialize also changed from (set, scope, path, options) to (scope, set, path, defaults, as, options), and the scope, path and options readers are gone, so an initialize override or a hook that reads options breaks too. The pattern flags the removed method names, Routing::Mapper::Mapping references, and a Mapping reopen nested in module Routing / class Mapper, as class Mapper::Mapping inside module Routing, or in class ActionDispatch::Routing::Mapper, with only blank or comment lines (or ;) between. It misses a nested reopen with other code between those lines, or a bare Mapper::Mapping constant written inside module Routing, unless the code names a removed method. The dual-boot fallback in fix: keeps matching (it names normalize_conditions! and Routing::Mapper::Mapping) until the 4.1 branch is removed"
      fix: "Prefer removing the patch. Custom route metadata passed under defaults: (get '/posts/:id' => 'posts#show', defaults: { authorize: :admin }, or scope defaults: { ... }) still lands in params but never becomes a required default, on 4.1 and 4.2 alike, so url_for works without any patch. If the patch must stay, hook the method each side has: normalize_conditions! (no arguments) on 4.1, constraints(options, path_params) on 4.2, selected with NextRails.next?, both private like the methods they wrap (Module#prepend needs Ruby 2.0; on 1.9.3 use alias_method_chain inside the same branches). Port an override of normalize_defaults!, normalize_options! or normalize_path! to the 4.2 signature the same way. Hooking constraints on 4.1 raises ArgumentError at route draw. Rails 5.0 changes constraints again (it returns the options grouped by kind and no longer writes @conditions), so a 4.2 hook breaks at the next hop: drop the patch rather than re-hook it"
      variable_name: "MAPPER_NORMALIZE_CONDITIONS"

    - name: "Arel attribute used as a hash-condition value"
      kind: "breaking"
      pattern: "(?:(?<!\\?\\s)(?<!\\?)\\b\\w+:|[\"']\\w+[\"']:|(?::\\w+|[\"']\\w+[\"'])\\s*=>)\\s*(?:(?:::)?\\w+(?:::\\w+)*\\.)*arel_table\\[[^\\]\\n]+\\](?!\\s*\\.)"
      exclude: "\\A\\s*#"
      search_paths:
        - "app/"
        - "lib/"
      explanation: "From Rails 4.2.3 on (so on the 4.2.11.3 that gem 'rails', '~> 4.2.0' installs), a hash-condition value that the predicate builder has no special handler for becomes a bind value cast through the column type. An Arel attribute is such a value, so where(owner_id: Owner.arel_table[:id]) no longer compares two columns: the attribute is cast, an integer column gets owner_id = NULL and the query silently returns no rows, and a string column raises TypeError (can't cast Arel::Attributes::Attribute) when the query runs on an adapter that sends bind values (sqlite3), while mysql2 (no prepared statements on 4.2) quotes the attribute as a YAML string and silently returns no rows. Through 4.1 (and 4.2.0 to 4.2.2) the attribute passed through as a column-to-column comparison, except class-level find_by(column: attribute), whose statement cache already casts it from 4.2.0. Rails 5.0 keeps the 4.2.3 behavior. Matches a symbol or quoted key (key:, 'key':, :key =>, 'key' =>) followed by arel_table[...] on any receiver (Owner., self.class., klass.) or none, when no method call follows. A ternary written without a space before the colon (cond ? a: x) is skipped. A dotted 'table.column' => key is skipped: it is not a column of the model, so 4.2 does not bind it and the comparison still works, but Rails 5.0 turns it into a nested hash and binds it, so it breaks on the 4.2 to 5.0 hop. A nested hash under the model's own table name (posts: { owner_id: Owner.arel_table[:id] }) is flagged: 4.2 does not bind it either, but 5.0 does, so rewrite it now. A hash inside a trailing comment after code is still flagged. Any hash literal with such a value is flagged, so a sort-column map or an update_all hash shows up too; check that the hash reaches where, find_by or a scope before changing it. Not matched: a table held in a variable first (t = Owner.arel_table; where(owner_id: t[:id])), an attribute assigned to a variable and passed later, and an attribute passed to a scope that builds the hash itself (for_owner(Owner.arel_table[:id])). Search for those by hand when the app uses Arel tables"
      fix: "Build the predicate with Arel instead of a hash: where(Post.arel_table[:owner_id].eq(Owner.arel_table[:id])), or inside the model where(arel_table[:owner_id].eq(Owner.arel_table[:id])). It produces the same column-to-column SQL on 4.1 and 4.2, so no NextRails.next? conditional is needed. Pin each site with a test that checks the generated SQL or that the query returns rows"
      variable_name: "AREL_ATTRIBUTE_AS_VALUE"

  medium_priority:
    - name: "find/exists? with possible AR object argument"
      kind: "deprecation"
      pattern: "\\.(find|exists\\?)\\(\\s*@?[a-z_][a-zA-Z_0-9.]*\\s*\\)"
      exclude: "\\.(find|exists\\?)\\([^)]*\\.id\\s*\\)|\\.(find|exists\\?)\\(\\s*\\d+"
      search_paths:
        - "app/"
        - "lib/"
      explanation: "Rails 4.2 deprecates passing AR objects where an id is expected. Manual review needed — numeric ids and expressions ending in .id are already correct and excluded"
      fix: "Pass .id explicitly when the argument is an AR object (e.g., Comment.find(comment.id) instead of Comment.find(comment))"
      variable_name: "FIND_WITH_OBJECT"

    - name: "HTML sanitizer usage"
      kind: "breaking"
      pattern: "\\b(sanitize|strip_tags|strip_links|sanitize_css)\\b"
      exclude: ""
      search_paths:
        - "app/"
      explanation: "Rails 4.2 rewrites the sanitizer on top of Loofah/Nokogiri. Output may differ for edge-case inputs - review tests that assert sanitized output"
      fix: "Review test assertions on sanitized output. If differences are unacceptable, temporarily add gem 'rails-deprecated_sanitizer'"
      variable_name: "HTML_SANITIZER"

    - name: "Verify test_order is set"
      kind: "deprecation"
      pattern: "\\b(?:Rails\\.application|\\w+::Application)\\.configure\\b"
      exclude: "\\A\\s*#"
      unless_file_matches: "^[ \\t]*config\\.active_support\\.test_order[ \\t]*=[ \\t]*(?::[a-z]|ENV\\b|[\"'])"
      search_paths:
        - "config/environments/test.rb"
      explanation: "FILE MARKER (manual review required): when config.active_support.test_order is not set, Rails 4.2 falls back to :sorted (the 4.1 order) and emits a deprecation warning saying the default becomes :random in Rails 5. The warning comes from ActiveSupport::TestCase.test_order, which runs only when Minitest runs an ActiveSupport::TestCase subclass, so a suite that is RSpec only may never print it. A regex cannot detect a missing setting, so this pattern flags the configure block of config/environments/test.rb: both the Rails.application.configure form (generated by Rails 4.1 and later) and the <App>::Application.configure form (generated by Rails 4.0 and earlier, kept by apps that never regenerated the file). Open the file and check the setting is present, and check test/test_helper.rb for ActiveSupport::TestCase.test_order = (the 4.2 class setter writes the same value, and it runs after the environment file; 4.1 has no such setter, so during the dual boot use the config form). Commented-out configure lines are skipped. scan_patterns.rb skips the file when an uncommented line sets the option to a symbol, a string or an ENV value (nil, a comment or == still flags it); it cannot see the option in config/application.rb or ActiveSupport::TestCase.test_order = ... in test/test_helper.rb, so check there before adding it"
      fix: "If neither config.active_support.test_order in config/environments/test.rb nor ActiveSupport::TestCase.test_order = in test/test_helper.rb is present, add config.active_support.test_order = :sorted inside the configure block to keep the 4.1 order, or :random (the 4.2 generator value and the Rails 5 default) once the suite passes in random order. The line is safe on 4.1 with no conditional: the active_support.set_configs initializer only calls setters that ActiveSupport responds to, and 4.1 has no ActiveSupport.test_order=, so the line is ignored there"
      variable_name: "TEST_ORDER"

    - name: "Serialized attributes with custom coder"
      kind: "breaking"
      pattern: "serialize\\s+:\\w+,\\s*(JSON|YAML|\\w+Coder)"
      exclude: ""
      search_paths:
        - "app/models/"
      explanation: "Rails 4.2 changes how nil is handled with serialized attributes and custom coders - nil now saves NULL instead of passing through the coder"
      fix: "Review code that assigns nil to serialized attributes with custom coders. Check for tests that relied on the coder's nil representation (e.g., 'null' for JSON)"
      variable_name: "SERIALIZED_CUSTOM_CODER"

    - name: "Write into changed_attributes"
      kind: "breaking"
      pattern: "(?<![@\\w])changed_attributes(?:\\(\\))?(?:\\[(?:[^\\[\\]\\n]|\\[[^\\[\\]\\n]*\\])*\\][ \\t]*(?:\\*\\*|<<|>>|\\|\\||&&|[-+*\\/%|&^])?=(?![=~>])|\\s*&?\\.\\s*(?:delete|merge!|reverse_merge!|deep_merge!|update|reverse_update|store|clear|replace|shift|except!|slice!|reject!|select!|filter!|keep_if|delete_if|compact!|transform_values!|transform_keys!|\\[\\]=)(?![\\w!?]))"
      exclude: "\\A\\s*#|NextRails\\.next\\?"
      search_paths:
        - "app/"
        - "lib/"
      explanation: "From Rails 4.2.0, ActiveRecord's changed_attributes returns a frozen copy (super.reverse_merge(attributes_changed_in_place).freeze in attribute_methods/dirty.rb), so changed_attributes[name] = value, changed_attributes.delete(name), merge! and the other in-place Hash writers raise RuntimeError: can't modify frozen ActiveSupport::HashWithIndifferentAccess. Through 4.1 it returned the live hash, and code wrote into it to mark a record, often through a virtual attribute, as changed so save callbacks or versioning would run, or to drop a change. Reads keep working, and so do writes to the @changed_attributes instance variable and to changed_attributes of a plain ActiveModel::Dirty class (only the ActiveRecord override freezes), so check that a hit is inside an ActiveRecord model. A line that mentions NextRails.next? is skipped, so the dual-boot one-liner in fix: scans clean. A local variable named changed_attributes, and the name inside a string, are flagged too. Writes through indirection are missed: send(:changed_attributes), tap blocks, or a copy of the reference (h = changed_attributes; h.delete(k))"
      fix: "To mark an attribute changed with its current value as the old one, call attribute_will_change!(name), which works on 4.1 and 4.2. It records what the reader returns (nil when there is no reader) and keeps the first old value when the attribute is already changed, so it is not a drop-in swap for code that wrote a different value. To record a specific old value, use set_attribute_was(name, old) on 4.2 and keep changed_attributes[name] = old on 4.1 (NextRails.next? ? set_attribute_was(name, old) : changed_attributes[name] = old). To drop a change, use clear_attribute_changes([name]) on 4.2 and changed_attributes.delete(name) on 4.1. Both 4.2 methods are private ActiveModel::Dirty methods: call them from inside the model, and from another object (record.changed_attributes.delete(:token)) use record.send(:clear_attribute_changes, [:token]) or a public model method that wraps it; 4.1 has neither. clear_attribute_changes drops only a change made through a setter: on 4.2 a serialized or JSON column mutated in place stays in changes and is still saved. Keep each branch on one line with NextRails.next? (cond ? new : old), since the pattern skips lines that mention it. Remove the 4.1 branch once the upgrade ships"
      variable_name: "CHANGED_ATTRIBUTES_WRITE"

    - name: "Integration test request path without a leading slash"
      kind: "breaking"
      pattern: "(?:^|[{;]|\\bdo\\b)[ \\t]*(?:\\|[^|\\n]*\\|[ \\t]*)?(?:(?:get|post|put|patch|delete|head)(?:_via_redirect)?|(?:xhr|xml_http_request|request_via_redirect)[ \\t]*\\(?[ \\t]*:(?:get|post|put|patch|delete|head)[ \\t]*,)[ \\t]*\\(?[ \\t]*([\"'])(?![/?#\"']|[a-zA-Z][a-zA-Z0-9+.-]*://)[^\"'\\s]+\\1(?![ \\t]*do\\b)"
      exclude: "\\A\\s*#"
      search_paths:
        - "spec/requests/"
        - "spec/integration/"
        - "spec/api/"
        - "test/integration/"
      explanation: "Rails 4.2 builds the integration request URI as a string, scheme://host:port followed by the path (ActionDispatch::Integration::Session#build_full_uri, new in 4.2.0), so get \"users\" requests http://www.example.com:80users and rack-test raises URI::InvalidURIError (bad URI(is not URI?) on Ruby 2.x). Rails 4.1 resolved the path against \"/\" with URI#+, so the slash was optional. Flags get/post/put/patch/delete/head (and the _via_redirect, xhr, xml_http_request and request_via_redirect forms) at the start of a line or after {, ; or do, whose path argument is a string literal that starts with neither /, ? nor # and does not start with a scheme such as http:// (a URL inside the query, get \"auth/callback?return_to=http://x.com\", is still flagged: 4.2 parses it as a relative URI and the slash is still missing) (a leading ? or # still forms a valid URI on 4.2). Skipped: a string followed directly by do (rswag-style operation blocks such as get \"List users\" do), symbols (get :index), path helpers and variables, routing-spec hashes (get: \"users\"), receivers such as redis.get. Lines that start with # are skipped. Missed: paths with spaces inside #{ }, a path that starts with interpolation (get \"#{id}/edit\"), a request used as an expression (expect(get \"users\"), status = get \"users\"), a request followed by a block (get \"users\" do |r|, read as an rswag description), calls on a session object (sess.get \"users\"), a path on the next line, and request helpers kept in spec/support/ or test/support/, which are not searched because controller shared examples there pass action names (get \"show\"). A spec that includes Rack::Test::Methods directly (Grape or Sinatra apps under spec/api/) is not affected, since rack-test adds the slash itself"
      fix: "Add the leading slash (get \"/users\"), or use a path helper (get users_path). Both work on 4.1 and 4.2, so no dual-boot conditional is needed"
      variable_name: "INTEGRATION_RELATIVE_PATH"

    - name: "belongs_to with dependent: :destroy or :delete (cascade moves to after_destroy)"
      kind: "breaking"
      pattern: "^[^#\\n]*?\\bbelongs_to\\b[ \\t]*\\(?\\s*:\\w+(?:[^\\n#]*,[ \\t]*(?:#[^\\n]*)?\\r?\\n(?:[ \\t]*#[^\\n]*\\r?\\n)*)*?[^\\n#]*?(?:\\bdependent:|:dependent[ \\t]*=>|[\"']dependent[\"'][ \\t]*=>)[ \\t]*:(?:destroy|delete)\\b"
      exclude: "\\A[ \\t]*#"
      search_paths:
        - "app/"
        - "lib/"
      explanation: "Rails 4.0 and 4.1 register a `belongs_to ..., dependent: :destroy` (or `:delete`) cascade as a before_destroy, from the shared association builder (activerecord-4.1.16 associations/builder/association.rb, `add_before_destroy_callbacks`). Rails 4.2.0 overrides it for belongs_to only and registers it as an after_destroy (activerecord-4.2.0 associations/builder/belongs_to.rb, `add_destroy_callbacks`; rails/rails#12380). has_one and has_many cascades stay before_destroy. Nothing raises or warns. On `record.destroy` the parent row is now deleted after the record's own row instead of before, so other destroy callbacks see a different set of rows, and a parent destroy that returns false no longer halts the record's destroy: on 4.1 `record.destroy` returned false and both rows stayed, on 4.2 the record is deleted, destroy reports success and the parent row stays. This is the 3.2 order again. A reciprocal pair (this belongs_to plus a has_one/has_many back with dependent: :destroy, BELONGS_TO_DEPENDENT in rails-40-patterns.yml) terminates on 4.2 only when the association back is re-read from the database: with an inverse, which 4.1 and 4.2 detect automatically for a plain has_one/belongs_to pair, the destroyed record is reused from memory and the pair still ends in SystemStackError on 4.2, as does the after_destroy workaround from the 4.0 entry; `inverse_of: false` on both sides lets it terminate. The pattern needs a symbol name right after `belongs_to` (so `belongs_to?` or `reflect_on_all_associations(:belongs_to)` is skipped) and matches `dependent: :destroy`, `:dependent => :destroy` and `:delete`, also when the option sits on a later line of a declaration wrapped after a trailing comma, after full comment lines inside it, in the `belongs_to(` newline `:name` form, and with CRLF line endings; that multi-line reach comes from the whole-file scanner (detection-scripts/scan_patterns.rb), a line grep only sees one-line declarations. It skips a commented-out declaration and text in a trailing comment. It misses a declaration with a `#` before the option on the same line (a `\"#{...}\"` class_name, or a string holding `#` earlier on the line), an option set through `with_options dependent: :destroy do ... belongs_to :x ... end`, and a scope lambda whose body spans lines before `dependent:`"
      fix: "Default: keep the option and accept the 4.2 order, which later Rails versions keep. For each hit, check the record's destroy callbacks and tests for code that expects the parent to be deleted first, or a failed parent destroy to stop the record's destroy, and pin the order with a spec on the DELETE statements the destroy runs. If the old order matters, drop the option and declare `before_destroy { account.destroy if account }` with the association's own name (`account.delete` for `dependent: :delete`; the reader applies the association's scope and works for a polymorphic belongs_to) where the association was: it runs the cascade before the record's own delete on 4.1 and on 4.2, so it can ship before the bump. A false return from it halts the destroy on 4.1 and 4.2; returning `false` is deprecated on 5.0 and stops halting on 5.1, where the halt needs `throw(:abort)`, so revisit it on those hops. Do not use that form on a reciprocal pair, where it brings back the 4.0/4.1 recursion"
      variable_name: "BELONGS_TO_DEPENDENT_DESTROY"

    - name: "serve_static_assets config"
      kind: "deprecation"
      pattern: "serve_static_assets"
      exclude: ""
      search_paths:
        - "config/environments/"
      explanation: "Rails 4.2 renames config.serve_static_assets to config.serve_static_files"
      fix: "Rename config.serve_static_assets to config.serve_static_files. In production.rb, consider using ENV['RAILS_SERVE_STATIC_FILES'].present?"
      variable_name: "SERVE_STATIC_ASSETS"

    - name: "form_authenticity_token in non-Rails forms"
      kind: "breaking"
      pattern: "form_authenticity_token"
      exclude: ""
      search_paths:
        - "app/"
      explanation: "Rails 4.2 masks CSRF tokens per-request for SSL attack mitigation. Non-Rails forms or clients that cache the token break"
      fix: "Fetch the token per request or use Rails form helpers that handle masking automatically"
      variable_name: "CSRF_TOKEN_MASKING"

    - name: "Arel union / intersect of relations drops bind values"
      kind: "breaking"
      pattern: "(?<!Regexp)(?<![_$])\\.(?:union|intersect)(?:\\(|[ \\t]+(?=[@:A-Za-z_(]))|\\b(?:Arel::)?Nodes::(?:Union(?:All)?|Intersect|Except)\\.new\\b"
      exclude: "\\A\\s*#|\\bSet(?:\\.new\\([^()]*\\)|\\[[^\\[\\]]*\\])\\.union\\b|\\.to_set\\.union\\b|(?:^|[\\s=(,])\\[[^\\[\\]]*\\]\\.union\\b"
      search_paths:
        - "app/"
        - "lib/"
      explanation: "Rails 4.2 keeps the values of where(column: value) as bind values on the relation until the query runs. Relation#union and #intersect (passed through to Arel::SelectManager) and Arel::Nodes::Union / UnionAll / Intersect / Except.new combine the Arel trees but not the bind values, so the SQL reaches the database with an unfilled placeholder. SQLite gets ? and binds it as NULL, so the query silently returns no rows; MySQL gets ? and raises a syntax error; PostgreSQL gets $1 and raises \"there is no parameter $1\". On 4.1 the same code inlined the values and worked, unless a relation came from an association. Usual shape: Model.from(Model.arel_table.create_table_alias(a.union(b), :alias).to_sql). Calls from the active_record_union gem (Relation#union / #union_all) keep their bind values and are fine; the regex cannot tell them apart, so check the Gemfile before rewriting. Regexp.union, Set.new(...).union, Set[...].union, .to_set.union, array literals, lodash _.union and comment lines are skipped; a Set or Array held in a plain variable (ids.union(other)) is still flagged. Relation#except is the Active Record method, not Arel, and is not flagged; arel.except(other) is missed"
      fix: "Build the subquery from each relation to_sql, which quotes and inlines the values: Model.from(\"(#{a.to_sql} UNION #{b.to_sql}) alias\"). This runs on 4.1 and 4.2 with no NextRails.next? branch, except on 4.1 for a relation built from an association (user.posts), whose to_sql still prints ?. For those, or to keep a relation instead of a FROM string, add gem \"active_record_union\", \"~> 1.3\" (1.4 needs Rails 6) and call a.union(b) / a.union_all(b), which keeps both sets of bind values on 4.1 and 4.2. Use UNION ALL only where the old code passed :all"
      variable_name: "AREL_UNION_BINDS"

    - name: "Foreigner gem"
      kind: "migration"
      pattern: "gem.*['\"]foreigner['\"]"
      exclude: ""
      search_paths:
        - "Gemfile"
      explanation: "Rails 4.2 adds native foreign key support (add_foreign_key, t.references foreign_key: true) that can replace Foreigner for most cases"
      fix: "Remove gem 'foreigner', run bundle install, run bin/rake db:schema:dump, verify db/schema.rb. Note: Rails FK support is a subset of Foreigner"
      variable_name: "FOREIGNER"
    - name: "ConnectionAdapters::Column.new with the old (name, default, sql_type) arguments"
      kind: "breaking"
      pattern: "\\bConnectionAdapters::(?:\\w+Adapter::)?Column\\s*\\.new\\b(?![ \\t]*\\(?[ \\t]*\\*)"
      exclude: "\\A\\s*#"
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
        - "spec/"
        - "test/"
      explanation: "Rails 4.2 changes Column#initialize from (name, default, sql_type = nil, null = true) to (name, default, cast_type, sql_type = nil, null = true), and the column delegates type, limit, precision, scale and every cast (type_cast_from_user, type_cast_from_database, ...) to cast_type. Code that builds fake columns (the tableless-model recipe columns << Column.new(name.to_s, default, sql_type.to_s, null), or a virtual typed field appended to a real model's columns) still loads, but the sql_type string lands in cast_type and the first assignment, read or column lookup raises NoMethodError: undefined method `type_cast_from_user' for \"boolean\":String (or type_cast_from_database, type, limit). Matches ConnectionAdapters::Column.new and ConnectionAdapters::<X>Adapter::Column.new (AbstractMysqlAdapter::Column takes the same arguments; 4.2 drops the Mysql2Adapter and MysqlAdapter Column subclasses, so those names resolve to it). A call split before .new (Column then .new on the next line) is matched by the whole-file scanner. A splat call, Column.new(*args), is skipped: it is the dual-boot shape the fix uses, so check any other splat call by hand. Misses a bare Column.new reached through a reopened or included ConnectionAdapters module or a constant alias"
      fix: "Build the cast type without a connection on 4.2 and insert it as the third argument only there (ActiveRecord::Type does not exist on 4.1): args = [name.to_s, default, sql_type.to_s, null]; args.insert(2, ActiveRecord::Type.const_get(VIRTUAL_CAST_TYPES.fetch(sql_type.to_s.sub(/\\(.*/, \"\"))).new) if NextRails.next?; Column.new(*args). VIRTUAL_CAST_TYPES maps boolean, integer, date, datetime, time, decimal, float and binary to the Type class of the same name, timestamp to DateTime, and string, text and an empty type to Value (it casts nothing, as 4.1 did; Type::String would to_s an Array). Value#type is nil, so code that reads column.type for those fields (form builders choosing a textarea) needs Type::String / Type::Text instead. fetch raises KeyError on an undeclared type at class load: add it to the map. The splat call is not flagged by this pattern. Do not use connection.lookup_cast_type: it needs a connection at class load and on PostgreSQL raises for string. Drop the insert after the upgrade. A table-backed model can use the 4.2 class method attribute :flag, ActiveRecord::Type::Boolean.new instead (absent on 4.0 and 4.1); a set attribute with no table column still goes into the INSERT on 4.2.0, and on later 4.2 releases when partial_writes is off. The long-term replacement is the Rails 5.0 attributes API"
      variable_name: "COLUMN_NEW_SQL_TYPE_ARG"

    - name: "Numeric#ago / until / since / from_now on a bare number"
      kind: "breaking"
      pattern: "(?:(?<![\\w.])\\d+(?:_\\d+)*(?:\\.\\d+)?|\\.(?:to_[if]|abs))\\.(?:ago|until|since|from_now)(?![\\w?!])|(?:\\.(?:round|floor|ceil)(?:\\(\\s*\\d*\\s*\\))?|(?<![\\w)\\]])\\([^()*\\/]*[*\\/][^()]*\\))\\.(?:ago|until|since|from_now)(?![\\w?!(])"
      exclude: "\\A\\s*(?:#(?!\\{)|<%#)"
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
        - "spec/"
        - "test/"
        - "db/"
      explanation: "Rails 4.1 deprecated calling ago, until, since and from_now on a plain number (`Calling #ago or #until on a number (e.g. 5.ago) is deprecated`, and the same for #since / #from_now). Rails 4.2 removes them from Numeric, so `5.ago` raises NoMethodError (undefined method `ago' for 5:Fixnum, or 5:Integer on Ruby 2.4+). Methods on a Duration (`5.seconds.ago`) are unchanged. The pattern flags a numeric literal (`5.ago`, `1.5.since`, `3_600.from_now`), a `.to_i`, `.to_f` or `.abs` result (`1.day.to_i.ago`), a `.round`, `.floor` or `.ceil` result with no argument to the time method (`x.round.ago`, `x.round(2).ago`), and a parenthesized expression with `*` or `/` that is not a method call's argument list, again with no argument to the time method (`(2.hours * 3).ago`, `(TIMEOUT * 4).ago`, `(60 * 60).ago`): through 4.2 a Duration has no `*` or `/` of its own, method_missing hands them to the Integer value and returns a plain Integer, so those calls warn on 4.1 and raise on 4.2. The parenthesized branch spans lines inside the parentheses. Duration `+` and `-` keep a Duration and are not flagged. Time#ago / since and Date#ago / since always take an argument, so the `.round` and parenthesized shapes are flagged only without one: `Time.current.round.ago(1.hour)` and `(Time.now - 2 * 3600).since(1.hour)` are Time calls, and `(TIMEOUT * 4).ago(t)` is missed. Lines that start with `#` (not `#{`) or with an ERB `<%#` comment are skipped; a trailing comment or a string literal such as `\"retry in 5.ago\"` is still flagged. Not detected: a variable holding seconds (`timeout.ago`), such as an Integer read from YAML, ENV or a settings table and handed to a gem that calls ago on it, an Integer on the left of `+` (`(5 + 1.hour).ago`), other Integer-returning calls (`items.count.ago`), parentheses with no `*` or `/` (`(1.day.to_i).ago`), and `1e3.ago` or `0x10.ago`. Those show up as the 4.1 deprecation warning in logs and test output, so fix every such warning on 4.1 before the bump. A Duration plus a product inside one pair of parentheses (`(1.day + 2 * 3.hours).ago`) is flagged although the sum is a Duration, and a nested parenthesis inside the expression hides the call"
      fix: "Give the number a unit: `5.ago` becomes `5.seconds.ago`, `timeout.from_now` becomes `timeout.seconds.from_now`, `(2.hours * 3).ago` becomes `(2.hours * 3).seconds.ago` or `Time.current - 2.hours * 3`. For a value read from configuration, convert it where it is read (`setting.seconds`) so every consumer gets a Duration. A Duration is `==` to its Integer, does arithmetic like it and serializes to JSON as it, but `Integer === duration` (so `case x when Integer`), `eql?` and Hash-key lookups treat it as a different object on 4.1 and 4.2, so check the setting's other consumers before converting at read time. `.seconds` exists on every Rails version, so the fix runs on 4.1 and 4.2 with no NextRails.next? branch"
      variable_name: "NUMERIC_AGO_WITHOUT_UNIT"

    - name: "Column#type_cast instance calls"
      kind: "breaking"
      pattern: "\\.type_cast(?:\\((?![ \\t\\n]*\\))(?!(?:(?:\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*'|\\((?:\"[^\"\\n]*\"|'[^'\\n]*'|[^()\"'])*\\)|[^()\"',]))*,[ \\t\\n]*[^\\s)&])|[ \\t]+(?!(?:if|unless|and|or|rescue|while|until|then|do)\\b)(?=[\\w@:\"'\\[(]|[-*!%]\\S)(?![^\\n,#]*,))|(?:\\b(?:send|public_send|try!?)|\\b__send__)(?:\\([ \\t]*(?::type_cast|\"type_cast\"|'type_cast')[ \\t]*,(?!(?:(?:\"(?:[^\"\\\\\\n]|\\\\.)*\"|'(?:[^'\\\\\\n]|\\\\.)*'|\\((?:\"[^\"\\n]*\"|'[^'\\n]*'|[^()\"'])*\\)|[^()\"',]))*,[ \\t\\n]*[^\\s)&])|[ \\t]+(?::type_cast|\"type_cast\"|'type_cast')[ \\t]*,(?![^\\n,#]*,))"
      exclude: "\\A[ \\t]*(?:#|def\\s)"
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
        - "spec/"
        - "test/"
      explanation: "Rails 4.2.0 removed the instance method ActiveRecord::ConnectionAdapters::Column#type_cast(value) (defined in column.rb through activerecord 4.1.16). A 4.2 column delegates casting to its cast_type through type_cast_from_database and type_cast_from_user, and Type::Value#type_cast is private, so column.type_cast(value) raises NoMethodError. Typical callers cast a param or a calculation result through Model.columns_hash[name].type_cast(value) or column_for_attribute(name).type_cast(value). One-argument calls are flagged, with or without parentheses (a trailing comma or a &block argument still counts as one argument), plus send, public_send, __send__, try and try! with :type_cast or \"type_cast\", with or without parentheses. A zero-argument type_cast() is skipped. try(:type_cast, value) does not raise on 4.2: ActiveSupport try checks respond_to? and quietly returns nil. The two-argument connection.type_cast(value, column) quoting method still exists on 4.2 and is skipped when its comma is at the top level of the call or inside one level of nested parentheses (deeper nesting is flagged; commas inside string literals are ignored, but a parenthesis inside a string inside nested parentheses can still hide a real call, and a paren-less call with a comma later on the line is skipped). Any other object with a public one-argument type_cast is flagged too, so check that the receiver is a column. The removed class-level helpers (Column.value_to_boolean and friends) are a separate change"
      fix: "First check whether the cast does anything: minimum and maximum already cast their result through the column on 4.1 and 4.2, so the cast can simply go. Otherwise branch on the Rails version: NextRails.next? ? column.type_cast_from_database(value) : column.type_cast(value). type_cast_from_database gives the 4.1 result for string, integer, decimal, boolean and datetime inputs, with one difference: a string column now returns a String for any value (5 becomes \"5\"). type_cast_from_user is what an attribute writer uses, but it differs more: a blank string cast through an integer column gives nil instead of 0. Rails 5.0 replaces both with Model.type_for_attribute(name).cast(value)"
      variable_name: "COLUMN_TYPE_CAST_INSTANCE"

    - name: "ConnectionAdapters::Column class-level cast helpers removed"
      kind: "breaking"
      pattern: "(?:(?<=ConnectionAdapters::|Adapter::)|(?<![\\w:]))(?:PostgreSQL|SQLite3)?Column\\s*(?:\\.|::)\\s*(?:value_to_(?:boolean|integer|decimal|date)|string_to_(?:dummy_)?time|string_to_date|binary_to_string)(?![\\w?!])|(?:(?<=ConnectionAdapters::|Adapter::)|(?<![\\w:]))(?:PostgreSQL|SQLite3)?Column\\s*\\.\\s*(?:public_send|try!?)\\s*\\(?\\s*[:\"']+(?:value_to_(?:boolean|integer|decimal|date)|string_to_(?:dummy_)?time|string_to_date|binary_to_string)(?![\\w?!])|(?:(?<=ConnectionAdapters::|Adapter::)|(?<![\\w:]))(?:PostgreSQL|SQLite3)?Column\\s*\\.\\s*(?:__send__|send|method)\\s*\\(?\\s*[:\"']+(?:value_to_(?:boolean|integer|decimal|date)|string_to_(?:dummy_)?time|string_to_date|binary_to_string|new_(?:date|time)|fast_string_to_(?:date|time)|fallback_string_to_(?:date|time)|microseconds)(?![\\w?!])|(?:(?<=ConnectionAdapters::|Adapter::)|(?<![\\w:]))PostgreSQLColumn\\s*(?:(?:\\.|::)\\s*|\\.\\s*(?:__send__|public_send|send|try!?|method)\\s*\\(?\\s*[:\"']+)(?:point_to_string|string_to_(?:point|bit|hstore|json|cidr|array)|(?:hstore|json|array|range|cidr)_to_string)(?![\\w?!])|(?:(?<=ConnectionAdapters::|Adapter::)|(?<![\\w:]))PostgreSQLColumn::Cast(?!\\w)"
      exclude: "\\A\\s*#"
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
        - "spec/"
        - "test/"
      explanation: "Rails 4.2 moved type casting into ActiveRecord::Type and removed the class-level cast helpers of ActiveRecord::ConnectionAdapters::Column. Public in 4.1 and gone in 4.2.0: value_to_boolean, value_to_integer, value_to_decimal, value_to_date, string_to_time, string_to_dummy_time, binary_to_string. Protected in 4.1 (reachable only through send or method, which ignore visibility) and gone in 4.2.0: new_date, new_time, fast_string_to_date, fast_string_to_time, fallback_string_to_date, fallback_string_to_time, microseconds. MysqlAdapter::Column also had a public string_to_date. The PostgreSQLColumn::Cast helpers (string_to_hstore, string_to_json, string_to_array, hstore_to_string and the rest) and the Cast module itself are gone too. Every caller raises NoMethodError on 4.2 (a try call returns nil instead), and 4.1 emits no deprecation warning first. Apps mostly use value_to_boolean to cast checkbox and flag params. Matches the receivers Column (after ConnectionAdapters:: or an adapter such as Mysql2Adapter::, or bare after include ActiveRecord::ConnectionAdapters), PostgreSQLColumn and SQLite3Column, called directly or through send, __send__, public_send, try or method. App classes such as ReportColumn or Reports::Column are skipped. Missed: calls through column.class or self.class, and bare calls inside a Column subclass"
      fix: "Replace each call with app-owned code that runs on 4.1 and 4.2, so no version conditional is needed. value_to_boolean: return nil for an empty String, otherwise test membership in an app-owned Set of the true values [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON']. Keep it a Set: 4.1 compares with eql?, so 1.0 and BigDecimal 1 cast to false, and an Array would cast them to true. Do not read Column::TRUE_VALUES (removed in 5.0) or call ActiveRecord::Type::Boolean (absent on 4.1, renamed methods on 5.0, and on 4.2 it logs a deprecation for values outside its true and false lists). value_to_integer: map true and false to 1 and 0, otherwise value.to_i rescue nil (4.1 returned nil for a value with no to_i, such as a Date or a Hash). value_to_decimal: value.to_d when value responds to to_d, otherwise value.to_s.to_d (require 'bigdecimal/util'). value_to_date, string_to_time, string_to_dummy_time and the protected helpers: copy the 4.1.16 method bodies (column.rb) into an app module, with the Format::ISO_DATE and ISO_DATETIME regexes (gone in 5.0) and ActiveRecord::Base.default_timezone. TimeZone#parse is not a drop-in: it raises on a month of 13, rolls 2014-02-30 over to March, and shifts a date with an offset into the next day where value_to_date returned nil or the written date. binary_to_string on the base Column returns its argument: drop the call; only SQLite3Column overrides it (it forces ASCII-8BIT), so copy that override for a SQLite3Column call. For a call on another adapter subclass (PostgreSQLColumn.string_to_time, which maps infinity, the MySQL Column string_to_time / string_to_date, the PostgreSQLColumn::Cast helpers) copy that subclass method. Pin the replacement with a spec that covers each input the old helper saw"
      variable_name: "COLUMN_CAST_CLASS_METHODS"

    - name: "Column default read through the column object"
      kind: "breaking"
      pattern: "(?:\\bcolumns_hash(?:\\([^)\\n]*\\))?(?:\\[[^\\]\\n]+\\]|\\.fetch\\([^)\\n]*\\))|\\bcolumn_for_attribute\\([^)\\n]*\\)|\\bcolumns(?:\\([^)\\n]*\\))?\\.(?:find|detect)[ \\t]*{(?:[^{}#\\n]|#(?!{)|#?{[^{}\\n]*})*}|\\bcolumns(?:\\([^)\\n]*\\))?\\.index_by[ \\t]*\\([ \\t]*&:name[ \\t]*\\)\\[[^\\]\\n]+\\]|(?:(?<![.\\w])|(?<=\\bself\\.))column)(?:&?\\.default\\b(?![?!]|\\.nil\\?|[ \\t]*=[^=~>])|&?\\.(?:try|public_send|send)(?:\\([ \\t]*|[ \\t]+):default\\b[ \\t]*\\)?)"
      exclude: "\\A\\s*#"
      search_paths:
        - "app/"
        - "lib/"
        - "config/"
        - "db/"
        - "spec/"
        - "test/"
      explanation: "Rails 4.1 typed a column's default when it built the column (Column#initialize called extract_default), so Model.columns_hash[\"active\"].default returned false for a boolean column and an Integer for an integer column. From 4.2.0 Column#default is the raw string the adapter read from the schema (\"604800\", and \"f\" for a false boolean on SQLite), with no warning. Arithmetic on it raises (Time.now - default: TypeError: can't convert String into an exact number), < and > against an Integer raise ArgumentError (comparison of String with 3 failed), == against an Integer or a boolean quietly returns false, and a false boolean default is now a non-empty String, so it is truthy. Matches .default, &.default and try / send / public_send with :default (with or without parentheses) on columns_hash[...] (also columns_hash(table)[...] from the schema cache), columns_hash.fetch(...), column_for_attribute(...), a one-line columns.find / detect { } block, columns.index_by(&:name)[...], and a variable named column, @column or self.column (a column object from another library with that name is flagged too). .default.nil? is skipped: a nil default stays nil on 4.2. Missed: other variable names (c.default inside columns.each), a receiver-qualified column (field.column.default), a nested index (columns_hash[NAMES[0]]), a find block or a .default that spans lines"
      fix: "Read Model.column_defaults[\"name\"] instead. It returns the typed default on 4.0, 4.1 and 4.2, so plain columns need no version conditional. On 4.2 it goes through the model's attribute types, so a serialize'd column's default comes back deserialized there: check those columns on both versions. For a column object that is not tied to a model (connection.columns(table)), cast on 4.2 only: NextRails.next? ? column.type_cast_from_database(column.default) : column.default"
      variable_name: "COLUMN_DEFAULT_RAW"

    - name: "Direct use of @attributes in a model"
      kind: "breaking"
      pattern: "(?<![@\\w])@attributes\\b"
      exclude: "\\A[ \\t]*#"
      search_paths:
        - "app/models/"
        - "config/initializers/"
      explanation: "Rails 4.2.0 keeps a record's attributes in an ActiveRecord::AttributeSet instead of a Hash. Swapping in a Hash breaks the first attribute read (NoMethodError: undefined method `fetch_value' for ...:Hash), Hash writes and reads such as []=, merge! and fetch raise NoMethodError, and @attributes['x'] silently returns an Attribute object instead of the value. Every direct @attributes reference in app/models/ and config/initializers/ is flagged: a plain Ruby class there with its own @attributes Hash is a known false positive, and lib/ and the rest of app/ are not scanned (the guide entry gives a grep for them)"
      fix: "Use the public API, which works on 4.1 and 4.2: read_attribute(:x) or read_attribute_before_type_cast(:x) for reads, write_attribute(:x, v) or self[:x] = v for writes. For extra non-column values, keep them out of @attributes: hold them in the model's own instance variable, load it in after_initialize and again after reload, and override attributes to merge them in (super.merge('extra' => @extra)) if callers need them there; record[:extra] and read_attribute(:extra) then return nil, so switch those calls to record.extra. Do not call attribute_will_change! for a non-column name: on 4.2 the partial UPDATE then includes it and fails with an unknown-column error (no such column on SQLite, column ... does not exist on PostgreSQL, Unknown column on MySQL). Also override becomes to copy the extra value: becomes builds the new record with klass.new, so after_initialize runs on blank attributes"
      variable_name: "ATTRIBUTES_IVAR_REPLACE"

  low_priority:
    - name: "Procfile rails server without explicit bind"
      kind: "breaking"
      pattern: "rails\\s+s(erver)?\\s*$|rails\\s+s(erver)?\\s+(?!-b|--binding)"
      exclude: "-b\\s+0\\.0\\.0\\.0|--binding"
      search_paths:
        - "Procfile"
        - "bin/"
      explanation: "Rails 4.2 (via Rack) binds rails server to localhost instead of 0.0.0.0 by default. Docker, Vagrant, and remote-access setups break"
      fix: "Add -b 0.0.0.0 to rails server commands that need external access"
      variable_name: "SERVER_BIND"

    - name: "Timecop gem in use"
      kind: "migration"
      pattern: "gem.*['\"]timecop['\"]|\\bTimecop\\."
      exclude: ""
      search_paths:
        - "Gemfile"
        - "test/"
        - "spec/"
      explanation: "Rails 4.2 adds built-in travel, travel_to, and travel_back helpers via ActiveSupport::Testing::TimeHelpers - these replace most Timecop use cases"
      fix: "Replace Timecop.freeze/return with travel_to/travel_back. Keep Timecop only if you use time-rate features (e.g., 1 sec = 1 hour)"
      variable_name: "TIMECOP"

dependencies:
  responders:
    check: true
    gem_name: "responders"
    message: "Required if controllers use respond_with or class-level respond_to"
    url: "https://github.com/heartcombo/responders"

  web-console:
    check: false
    gem_name: "web-console"
    message: "New Rails 4.2 default - interactive IRB console in development on error pages and via <%= console %> helper"
    url: "https://github.com/rails/web-console"

  rails-deprecated_sanitizer:
    check: false
    gem_name: "rails-deprecated_sanitizer"
    message: "Temporary fallback if the new Loofah-based sanitizer produces unexpected output (not recommended long-term, 4.2-only)"
    url: "https://github.com/rails/rails-deprecated_sanitizer"
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