Rails 4.0 patterns: bridge gem swaps (paper_trail, paranoia) + actionpack-page_caching dep#107
Open
JuanVqz wants to merge 4 commits into
Open
Rails 4.0 patterns: bridge gem swaps (paper_trail, paranoia) + actionpack-page_caching dep#107JuanVqz wants to merge 4 commits into
JuanVqz wants to merge 4 commits into
Conversation
JuanVqz
commented
May 27, 2026
| message: "Required if using ActiveResource" | ||
| url: "https://github.com/rails/activeresource" | ||
|
|
||
| paper_trail: |
Member
Author
There was a problem hiding this comment.
I'm unsure of adding this here because, yes, this is the right movement, but I'm not sure how to use it in the skill.
has_paper_trail internally calls has_many with the name from versions: / version:. On Rails 4 the symbol-required check raises ArgumentError: association names must be a Symbol from inside paper_trail's own code when the option value is a string. Boot-fatal for any model carrying the string form, but the stack trace points into the gem rather than the app, so operators tracing the error without context end up reading paper_trail source instead of fixing the option value. Fix is mechanical: change versions: "string" / version: "string" to versions: :symbol / version: :symbol. paper_trail accepts symbols on Rails 3.2 too, so the rewrite ships pre-bump and is backwards-compatible. Classified high_priority / kind: breaking — boot-fatal on Rails 4 for any model with the string form.
validates_as_paranoid is a class-method DSL provided by rails3_acts_as_paranoid (Rails-3-only soft-delete gem). The typical disposition during a 3.2 → 4.0 hop is to gate that gem `unless next?` in the Gemfile because it is unmaintained on Rails 4+. Once gated, call sites raise NoMethodError: undefined method 'validates_as_paranoid' for ... at model class-load on the next side. Boot-fatal — eager-load smoke test surfaces it. The paranoia replacement gem (the standard Rails-4-compatible soft-delete replacement that pairs with acts_as_paranoid) does NOT provide validates_as_paranoid. Its default_scope automatically excludes soft-deleted records from Model.where(...) uniqueness validations, so the explicit declaration is unnecessary on the next side. Fix is a one-line guard: validates_as_paranoid unless NextRails.next? Same guard works whether the codebase swaps to paranoia or simply leaves rails3_acts_as_paranoid gated `unless next?` — the call site is a no-op on the next side either way. Classified high_priority / kind: breaking — boot-fatal on next side when the providing gem is gated.
…_caching The dependencies registry was missing actionpack-page_caching entirely, and the existing actionpack-action_caching entry's message claimed it covered both caches_page and caches_action. That is wrong: at Rails 4.0 page caching and action caching were extracted into two separate gems with distinct release lines: - actionpack-action_caching — provides caches_action - actionpack-page_caching — provides caches_page Tightens the actionpack-action_caching message to caches_action only and adds a parallel entry for actionpack-page_caching so operators using either DSL get a hit pointing them at the right gem. No pattern changes; registry-only update.
- ACTION_CACHING fix now points caches_page to actionpack-page_caching and caches_action to actionpack-action_caching, so the new page_caching registry entry is actually referenced (was orphaned). - PAPER_TRAIL_STRING_VERSIONS regex widened to catch single-quoted strings too. - Reword its explanation: the ArgumentError originates in Rails-4 ActiveRecord (the symbol check added in 4.0.0), triggered once paper_trail is bumped to 3.0.0 on the next side. 2.7.2 pins Rails-3 AR (no check); 3.0.0 runs Rails-4 AR. - Add paper_trail dependency entry documenting the per-side dual-boot pin.
2f103ed to
e9ab191
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two Rails 4.0 bridge-gem swap patterns plus a missing dependencies registry entry.
PAPER_TRAIL_STRING_VERSIONS— new entry.has_paper_trailinternally callshas_manywith the name fromversions:/version:. On Rails 4, when the option value is a string, paper_trail's own code raisesArgumentError: association names must be a Symbol. Boot-fatal. Fix: changeversions: "string"→versions: :symbol(paper_trail accepts symbols on 3.2 too, so the rewrite ships pre-bump).VALIDATES_AS_PARANOID— new entry.validates_as_paranoidis a class-method DSL provided byrails3_acts_as_paranoid(Rails-3-only soft-delete gem). Typical 3.2 → 4.0 hop gates the gemunless next?in the Gemfile because it's unmaintained on Rails 4+. Call sites then raiseNoMethodErrorat model class-load on the next side. Theparanoiareplacement gem does NOT providevalidates_as_paranoid; its default_scope auto-excludes soft-deleted records fromModel.where(...)uniqueness validations. Fix:validates_as_paranoid unless NextRails.next?.actionpack-page_cachingadded to dependencies registry, and the existingactionpack-action_cachingmessage scoped tocaches_actiononly. At Rails 4.0 page caching and action caching were extracted into two separate gems with distinct release lines — the existing OSS entry conflated them.Both new patterns classified
high_priority/kind: breaking.Test plan
bin/validate-patterns rails-upgrade/detection-scripts/patterns/rails-40-patterns.ymlclean.versions:andversion:(singular/plural).