ActiveRecord relationship

hi

i have a question about relationships. if i have the folowing
classes/tables:

project --1--------------n-- iteration

iteration has a attribut "start_date". now i like to get all projects
whit at least one iteration where start_date = today. for other
calculatings i need all iterations related to this projects.

how can i do this whit activerecord?

something like this?

class Iteration < ActiveRecord::Base
  belongs_to :project
end

class Project < ActiveRecord::Base
  has_many :iterations

  def self.find_all_with_iteration_start_date (d)
    Iteration.find_all_by_start_date(d).collect { |i| i.project }
  end
end

projects = Project.find_all_with_iteration_start_date (today)

Could this be refactored:

projects = Iteration.find_all_by_start_date(today).collect { |i|
i.project }

I'm not sure it's a "refactoring" - it's exactly the same thing. The
original poster seemed to imply that he conceptually wanted the method
to be accessible through the Project model, so that's why I suggested
the convenience method I did.

-r