Post

Upgrading to Rails 7.2: Four Breaking Changes We Hit

Four breaking changes we hit upgrading to Rails 7.2: show_exceptions, array-containment SQL, connection pool locking, and assert_enqueued_email_with.

Four things broke moving from Rails 7.1 to 7.2.

show_exceptions no longer takes true/false

Setting it to false used to mean exceptions raise instead of rendering an error page, which specs relied on. That behavior now needs :none.

1
2
3
   # Raise exceptions instead of rendering exception templates.
-  config.action_dispatch.show_exceptions = false
+  config.action_dispatch.show_exceptions = :none

SQL generated for array containment changed

1
2
-    if link = where('course_ids @> \'{?}\'', course.id).first
+    if link = where('course_ids @> ARRAY[?]::bigint[]', course.id).first

lock_thread= is gone from the connection pool

1
NoMethodError: undefined method `lock_thread=' for an instance of ActiveRecord::ConnectionAdapters::ConnectionPool
1
2
-    ActiveRecord::Base.connection.pool.lock_thread = false
+    # ActiveRecord::Base.connection.pool.lock_thread = false

assert_enqueued_email_with takes params, not args

1
2
-    assert_enqueued_email_with UserMailer, :invitation, args: { invitation: invitation }
+    assert_enqueued_email_with UserMailer, :invitation, params: { invitation: invitation }

None of these needed a redesign, just a grep for each pattern across the codebase before merging the upgrade.

This post is licensed under CC BY 4.0 by the author.