ActiveRecord find_each ignores any order() criteria

One of the many benefits of test driven development is the ability to catch somewhat subtle bugs like this during developmentā€¦

The ActiveRecord find_each method is a great way to loop through large numbers of records. However, find_each will silently discard any order() criteria. Seems to me like a bug in find_each. However it was nice to find it in our rspec tests that verified certain things would be processed in a certain order.

ActiveRecord .count and .length are different when .group

When you do ActiveRecord query such as

the_list = Phone.joins(:beeps).where(["(beeps.store_id = ?) AND (userphone LIKE ?)", @store.id, "%#{submitted_phone}"])

the_list.count and the_list.length both return the integer # of records found, although .count results in an additional query against the database.

However, if you add a .group(:userphone), then the_list.count returns a hash of unique userphones => counts, while the_list.length returns the integer number of unique userphone found.