I have a relation like this
users = User.joins(:occupation).includes(:occupation)
count = 0
users.find_each do |u|
count += 1
end
count
count doesn't return the same number as users.count
It seems to always return a number less than what I anticipate. If I run this code I get the correct count
count = 0
users.each do |u|
count += 1
end
count
This returns the correct count
I was able to isolate the problem to my user to occupation relationship. However I am not sure what the underlying issue is. Any ideas what could cause this?