I have a situation where I need to select a larger set of records which need to be iterated through. In this case we want to break after we find a record that matches some logic condition.
If I do:
Model.where(field: value).limit(1000).each {|model| do_something }
It will instantiate an ActiveRecord model for all results even thought it’s possible to break after the first record.
We are currently using Rails 4.2.7.1
Is it possible to do this using ActiveRecord, or do I have work directly with SQL.
Thanks,
Dan