How to implement `ArgumentError` when using `find_each` with a scope in Rails 7?
I'm wondering if anyone has experience with I'm following best practices but I tried several approaches but none seem to work. I'm trying to configure I'm working with an `ArgumentError` when trying to use `find_each` with a custom scope in my Rails 7 application. I have a model `Order` and I'm trying to process orders with a specific status using a scope. However, when I run the following code: ```ruby Order.where(status: 'pending').find_each do |order| # Process each order order.process! end ``` I get the behavior message: `ArgumentError: wrong number of arguments (given 0, expected 1)`. I have implemented a custom instance method `process!` in my `Order` model that looks like this: ```ruby def process! # Logic to process the order raise ArgumentError, 'No arguments provided!' if args.empty? # Further processing end ``` The method `process!` requires at least one argument, but it seems that when calling it inside `find_each`, I'm not passing any arguments. I've tried modifying the call to include a dummy argument like this: ```ruby Order.where(status: 'pending').find_each do |order| order.process!(nil) end ``` But I still encounter the same behavior. I suspect there's some misunderstanding on how `find_each` interacts with my instance method. I've also checked that `args` in `process!` is not being set up correctly, but I need to pinpoint the scenario. Any suggestions on how to fix this or best practices for processing records in batches with required arguments in Rails? I'm using Ruby stable in this project. Hoping someone can shed some light on this. I've been using Ruby for about a year now. Am I missing something obvious? I recently upgraded to Ruby latest. This is for a desktop app running on Debian. Thanks for your help in advance!