How to Fix Rails 6.1 Relation `merge` Deprecation

1 · fastruby.io · May 15, 2023, 6:30 p.m.
Recently, while working on a Rails 6.1 to 7.0 upgrade, we encountered the following deprecation warning regarding changes made to ActiveRecord::Relation’s merge method: "Merging (#{node.to_sql}) and (#{ref.to_sql}) no longer maintains both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use relation.merge(other, rewhere: true)." In this article, we will talk about the expected behavior of merge, how it has changed and what to do in order to use t...