Forgive me if I've got my terminology wrong; I am still quite new to Ruby and Rails.
For school I am working on an RoR project as part of a team. I was pair programming with a teammate, who actually happens to be experienced in RoR; and I wrote something like the following:
d = self.deliverables.find_all_by_lifecycle_id(self.lifecycle_id)
My pair programming partner stopped me at this point and explained that this wouldn't work, because find_all_by_lifecycle_id
could only be resolved successfully if called by the Deliverable
model, which inherits from ActiveRecord::Base
(which is, in turn, the class responsible for providing such magical functionality). The self.deliverables
method returns an array, which doesn't offer the same capabilities. The alternate solution he suggested was to use a named scope.
I protested: "But... I'm pretty sure I tried it already... and it worked."
Sure enough, it does seem to work, as we discovered when we tested it out just to humor me. What was my teammate missing? I certainly don't have the expertise to see what could've been wrong about what he said (it made sense to me).