Rails 3: What is the default order of "MyModel.all"?

The default order is however the DB decided to return them.

See here for more info.

ActiveRecord Find All not sorting by ID?

If you want them in a specific order, you should do Model.order()


There is no order. You should watch your logs while learning about ActiveRecord to see what SQL is being generated. If there's no ORDER BY clause, there's no order. You may find that you get records back in the order in which they were inserted to the database but that's just coincidental and due to implementation within the database server. SQL results are explicitly unordered unless ORDER BY is present.

As for #first, that is also random without an order clause (at least, it is in rails 3).

You can specify the order quite easily:

MyModel.order(:some_attr) # all records sorted by some_attr
MyModel.order(:some_attr).first # First record in sorted order