Forum: Ruby on Rails :order question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ettore B. (Guest)
on 2006-05-03 20:59
(Received via mailing list)
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
Nicolas B. (Guest)
on 2006-05-03 20:59
(Received via mailing list)
That should do:

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

Regards,

Nicolas
Ettore B. (Guest)
on 2006-05-03 20:59
(Received via mailing list)
Thanks Nicolas, It works perfectly!

Il giorno 02/mag/06, alle ore 14:43, Nicolas B. ha scritto:
This topic is locked and can not be replied to.