Is there a way to pre-sort the children of a parent through ActiveRecord (Rails 3.2.13)?
So if you have a setup like this
class Parent < ActiveRecord::Base
has_many :children
[...]
class Children < ActiveRecord::Base
belongs_to :parent
Something like this:
p = Parent.where(:name => 'Diana').includes(:children, :order => 'd_o_b DESC')
That way when I call p.children
I am getting an array of objects ordered by birth, and not by their database ID.
Or do I just need to sort my array afterward?