Strange behavior when using `find_each` with custom scope in Rails 7.1
I'm working on a personal project and I'm relatively new to this, so bear with me... I'm experiencing unexpected behavior when trying to use `find_each` with a custom scope in my Rails 7.1 application. I have a model called `User` with a scope defined as follows: ```ruby class User < ApplicationRecord scope :active, -> { where(deleted_at: nil) } end ``` When I run the following code to process all active users: ```ruby User.active.find_each do |user| puts user.email end ``` I expect to see a list of user emails in the output. However, I'm getting the following behavior message: ``` ActiveRecord::StatementInvalid: PG::UndefinedTable: behavior: relation "users" does not exist ``` I have checked the database and the `users` table exists, and I've confirmed that my migrations have run successfully. Additionally, I have verified that other queries against the `User` model work as expected. To troubleshoot, I tried running the same query using `all` instead of the custom scope: ```ruby User.all.find_each do |user| puts user.email end ``` This works without any issues, and I can see the emails as expected. It seems like the question only occurs when using the custom `active` scope in combination with `find_each`. Could this be related to the way Rails builds the SQL query for `find_each`? I've also looked into the possibility of cached queries or scopes interfering, but nothing seems to resolve it. Any insights would be greatly appreciated, especially if anyone has faced a similar scenario! I'm working on a application that needs to handle this. What am I doing wrong? For context: I'm using Ruby on Linux.