I really do not know whether someone has already asked this question or not, if someone has already asked this, please let me know.
I want to use order with find_each. It should something like
Email.find_each(:order=> "id desc").do |email|
puts "email.id"
end
Thanks in advance
Since find_each
internally uses find_in_batches
, which forces order to be ascending on the primary key (id ASC
by default) and doesn't allow to change it, it's not possible.
More info here:
http://api.rubyonrails.org/classes/ActiveRecord/Batches.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With