You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refine rails-40 caching + paper_trail patterns from review
- 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.
Copy file name to clipboardExpand all lines: rails-upgrade/detection-scripts/patterns/rails-40-patterns.yml
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -174,12 +174,12 @@ upgrade_findings:
174
174
175
175
- name: "has_paper_trail with string :versions / :version option"
176
176
kind: "breaking"
177
-
pattern: "has_paper_trail.*versions?:\\s*\""
177
+
pattern: "has_paper_trail.*versions?:\\s*[\"']"
178
178
exclude: ""
179
179
search_paths:
180
180
- "app/models/"
181
-
explanation: "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 on Rails 4 for any model carrying the string form"
182
-
fix: "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"
181
+
explanation: "has_paper_trail forwards the `versions:` / `version:` option value straight into an internal `has_many` / `has_one` call as the association name, with no `to_sym`. This surfaces when paper_trail is bumped on the next side of a dual-boot (`gem \"paper_trail\", \"3.0.0\"` when next?, else `\"~> 2\"`): 2.7.2 pins to Rails-3 ActiveRecord, but 3.0.0 runs against Rails-4 ActiveRecord, which raises `ArgumentError: association names must be a Symbol` (the check ActiveRecord added in 4.0.0) when the name is a string. Boot-fatal on the next side for any model carrying the string form"
182
+
fix: "Change the option value to a symbol: `versions: \"audits\"` becomes `versions: :audits` (same for `version:`). Symbols are accepted on paper_trail 2.x and 3.0.0, so the rewrite ships pre-bump and is backwards-compatible. Single- and double-quoted strings both need rewriting"
explanation: "Page and action caching were extracted from Rails 4.0"
235
-
fix: "Add gem 'actionpack-action_caching' to Gemfile"
234
+
explanation: "Page and action caching were extracted from Rails 4.0 into two separate gems: caches_page moved to actionpack-page_caching, caches_action moved to actionpack-action_caching"
235
+
fix: "Add gem 'actionpack-page_caching' for caches_page and/or gem 'actionpack-action_caching' for caches_action, matching the methods the app actually uses"
236
236
variable_name: "ACTION_CACHING"
237
237
238
238
- name: "ActiveResource usage"
@@ -402,3 +402,9 @@ dependencies:
402
402
gem_name: "activeresource"
403
403
message: "Required if using ActiveResource"
404
404
url: "https://github.com/rails/activeresource"
405
+
406
+
paper_trail:
407
+
check: false
408
+
gem_name: "paper_trail"
409
+
message: "If the app uses paper_trail, pin it per side on the dual-boot: `gem \"paper_trail\", \"3.0.0\"` when next?, else `\"~> 2\"`. 3.0.0 runs on Rails-4 ActiveRecord, which requires symbol association names — see the PAPER_TRAIL_STRING_VERSIONS finding"
0 commit comments