I have a query like this:
locations = Location.order('id ASC').limit(10)
which returns an array of 500 or so records - all the records in the table - i.e. the limit clause is being ignored.
Yet if I put a .all on the end:
locations = Location.order('id ASC').limit(10).all
it works and returns 10 records.
This code is being run in a rake task and I am using PostgreSQL if that makes any difference.
Why is it doing that? Surely the .all should not be required. What am I missing?