sure you can write in plain sql using find_by_sql method. but it is an
easy query and it would easier doing it directly in rails code.
I'm not sure i understand what you want maybe it is :
Costumer.find :all, :include => :events, :order => 'customers.name'
and a question: maybe you made an errors by typing but why you wrote
customer (singular) in 'customer.name' ?
I want the Events (a selection on event.starttime) listed, but sorted
bij de Customer's name. Not all Events have a customer, so your query
went give them.
That why i tried:
Event.find(:all, :include => :customer, :order => 'customer.name')
I want the Events (a selection on event.starttime) listed, but sorted
bij de Customer's name. Not all Events have a customer, so your query
went give them.
That why i tried:
Event.find(:all, :include => :customer, :order => 'customer.name')
just add a condition: 'customers.id IS NOT NULL' (for mysql, other dbs
will have something equivalent').
There's also :joins instead of :include (which does mostly the same
joining, but doesn't actually instantiate the customer objects)
just add a condition: 'customers.id IS NOT NULL' (for mysql, other dbs
will have something equivalent').
There's also :joins instead of :include (which does mostly the same
joining, but doesn't actually instantiate the customer objects)