Skip to content

Rails 4.0 patterns: bridge gem swaps (paper_trail, paranoia) + actionpack-page_caching dep#107

Open
JuanVqz wants to merge 4 commits into
mainfrom
feature/rails-40-patterns-pr6
Open

Rails 4.0 patterns: bridge gem swaps (paper_trail, paranoia) + actionpack-page_caching dep#107
JuanVqz wants to merge 4 commits into
mainfrom
feature/rails-40-patterns-pr6

Conversation

@JuanVqz

@JuanVqz JuanVqz commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Two Rails 4.0 bridge-gem swap patterns plus a missing dependencies registry entry.

  • PAPER_TRAIL_STRING_VERSIONS — new entry. has_paper_trail internally calls has_many with the name from versions: / version:. On Rails 4, when the option value is a string, paper_trail's own code raises ArgumentError: association names must be a Symbol. Boot-fatal. Fix: change versions: "string"versions: :symbol (paper_trail accepts symbols on 3.2 too, so the rewrite ships pre-bump).
  • VALIDATES_AS_PARANOID — new entry. validates_as_paranoid is a class-method DSL provided by rails3_acts_as_paranoid (Rails-3-only soft-delete gem). Typical 3.2 → 4.0 hop gates the gem unless next? in the Gemfile because it's unmaintained on Rails 4+. Call sites then raise NoMethodError at model class-load on the next side. The paranoia replacement gem does NOT provide validates_as_paranoid; its default_scope auto-excludes soft-deleted records from Model.where(...) uniqueness validations. Fix: validates_as_paranoid unless NextRails.next?.
  • actionpack-page_caching added to dependencies registry, and the existing actionpack-action_caching message scoped to caches_action only. 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.yml clean.
  • Reviewer confirms PAPER_TRAIL regex matches both versions: and version: (singular/plural).
  • Reviewer sanity-checks the actionpack-page_caching URL and message.

@JuanVqz JuanVqz self-assigned this May 26, 2026
@JuanVqz JuanVqz requested review from etagwerker and removed request for etagwerker May 26, 2026 15:02
message: "Required if using ActiveResource"
url: "https://github.com/rails/activeresource"

paper_trail:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JuanVqz JuanVqz requested review from arielj and etagwerker May 27, 2026 23:11
@JuanVqz JuanVqz marked this pull request as ready for review May 27, 2026 23:11
JuanVqz added 4 commits July 3, 2026 20:43
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.
@etagwerker etagwerker force-pushed the feature/rails-40-patterns-pr6 branch from 2f103ed to e9ab191 Compare July 4, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant