Skip to content

Commit 2f103ed

Browse files
committed
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.
1 parent 8bbe917 commit 2f103ed

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

rails-upgrade/detection-scripts/patterns/rails-40-patterns.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ upgrade_findings:
174174

175175
- name: "has_paper_trail with string :versions / :version option"
176176
kind: "breaking"
177-
pattern: "has_paper_trail.*versions?:\\s*\""
177+
pattern: "has_paper_trail.*versions?:\\s*[\"']"
178178
exclude: ""
179179
search_paths:
180180
- "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"
183183
variable_name: "PAPER_TRAIL_STRING_VERSIONS"
184184

185185
- name: "validates_as_paranoid (rails3_acts_as_paranoid DSL)"
@@ -231,8 +231,8 @@ upgrade_findings:
231231
exclude: ""
232232
search_paths:
233233
- "app/controllers/"
234-
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"
236236
variable_name: "ACTION_CACHING"
237237

238238
- name: "ActiveResource usage"
@@ -402,3 +402,9 @@ dependencies:
402402
gem_name: "activeresource"
403403
message: "Required if using ActiveResource"
404404
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"
410+
url: "https://github.com/paper-trail-gem/paper_trail"

0 commit comments

Comments
 (0)