Order a Find Based on Attribute of Related Table

I have two tables in a one-to-one relationship. Let’s call them
orders and invoices. In the “list” page for “invoices”, how do I setup
my find so I can display them in order of “created_at” dates of the
“orders” table, instead of “created_at” of the “invoices” table?

I thought I could do something like this, but it returns “no method
error”.

@invoices = Invoice.find(:all).order.find(:all, :order => ‘created_at
DESC’)

or

@invoices = Invoice.find(:all, :order => “#{Invoice.order.created_at}
DESC”)

You Rock!!

or

@invoices = Invoice.find(:all, :order => “#{Invoice.order.created_at}
DESC”)

Invoice.find(:all, :include => [:orders], :order => ‘orders.created_at
DESC’)