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)