Is passing a raw class to an Active Record query really deprecated?

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


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?

The intend was not to support that anymore, mostly because the framework had a special class just to handle that case. The class is now gone but the behavior is still the same so it seems we didn’t had to deprecate that code in the first place.

So, I’d say, you can continue to use that code.


Okay, thanks for clearing that up!