:order question


#1

Hi!
I’ve two models:
Project has_many :works
Work belongs_to :project

Work contains :year_start and :year_end

I’ve setup a class method to retrieve the first and last year of my
Project.works

How could I get projects ordered by ‘first’ year?

Thanks,
Ettore


#2

That should do:

Projects.find(:all, :include => ‘works’, :order => ‘works.year_start’)

Regards,

Nicolas


#3

Thanks Nicolas, It works perfectly!

Il giorno 02/mag/06, alle ore 14:43, Nicolas B. ha scritto: