has_many :through is great. Is there anyway to find the association that it went through? Example: class Student has_many :projects has_many :grades, :through => :projects end student.grades[3].project Is it clear what I''m asking? How would this be done? -- Posted via http://www.ruby-forum.com/.
Robert James wrote:> has_many :through is great. Is there anyway to find the association > that it went through? > > Example: > > > class Student > has_many :projects > has_many :grades, :through => :projects > end > > student.grades[3].project > > Is it clear what I''m asking? How would this be done? > >I''ve been playing around with the same thing today. Here''s what I know so far... grade[3].find_all_in_projects(["student_id = ?", student.id) should return an array of projects associated with this grade and student. I''m still trying to nail down a more elegant way to get at that join object. Let me know if you figure out anything useful.
Robert James wrote:> has_many :through is great. Is there anyway to find the association > that it went through? > > Example: > > > class Student > has_many :projects > has_many :grades, :through => :projects > end > > student.grades[3].project > > Is it clear what I''m asking? How would this be done?I just wrote something up on this a few hours ago: http://blog.hasmanythrough.com/articles/2006/06/30/working-with-the-relationship-model -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/.