Topic: Re: rewriting relationship methods
I guess I'll approach this in baby steps and who knows maybe I'll get the answers to my overall questions:
Say I have a Project model with a has_many relationship to a Milestone Model with a has_many relationship to a Deed model.
The has_many gives me the method @project.milestones. And of course by doing something like:
for @milestone in @project.milestones
I can access all the deeds that belong to the milestones. But now I'd like to select only the milestones that have an attribute (field in DB) called complete set to 1, and also order by a field called name. How can I have an iterable list returned that still treats each item as an instance of a model? I've tried writing instance methods in the model using find_by_sql and though the returned items have the fields of the table as attributes they don't have any of the instance methods i've defined in their model.
Hope that makes sense.
-SICP (Abelson, Sussman)