What is the default order from a has_many relationship in Rails?
Thought that in the ActiveRecord:Base
the default_scope
was order: 'created_at ASC
', but I had to specify to get it ordering properly.
I have looked in the docs and in the source code, but I could not find any reference on that!
There is no order specified by default, so they will be ordered by how the database returns them. Usually this is by ID or insert order. The created_at column is only there if you specify it in your migrations so it wouldn't make sense for that to be the default order column.
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