I’m currently upgrading an app from Rails 5.0 to Rails 5.1 (and beyond, eventually). Currently, we have lots of queries such as
Person.where(type: FancyPerson)
with FancyPerson
being an STI subtype. Now on 5.0, this generates lots of deprecation warnings:
Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead.
At first I assumed this meant I needed to convert all the queries to something like
Person.where(type: FancyPerson.name)
but now I’m actually using 5.1, the deprecation warning is gone, and the previous code still generates exactly the same SQL.
I traced through the code, and this seems to be where Class objects now get converted into a query param. So why was the warning previously there, and does Rails still intend to support this usage?