I have run into this deprecation warning in my code base, and I’m not really sure I understand what the purpose of it is, or if it’s a bug in this particular case. I have a model that does a query in a validator to ensure records aren’t created too frequently. When creating a model using find_or_create_by, I get the deprecation warning (I created an example case here: deprecation.rb · GitHub). However if I change find_or_create_by to create, it works and I get no deprecation warning.
I’m not sure that it makes sense for the behaviour to need to be different here, but it seems to be because create is using Persistence#create whereas find_or_create_by uses Relation#create, which calls _deprecated_scope_block if given a hash.
Is this a bug? Having to add default_scoped (which, maybe just me, but makes me think of default scopes, which my class does not have) in one case or not the other feels strange to me.