Hello there,
a Person has_many projects, and a Project has_many tasks. Thus, a Person also has many tasks.
Is there a way to write this has_many in the Person class without using :finder_sql?
Thanks a bunch in advance! Giuseppe
Hello there,
a Person has_many projects, and a Project has_many tasks. Thus, a Person also has many tasks.
Is there a way to write this has_many in the Person class without using :finder_sql?
Thanks a bunch in advance! Giuseppe
class Task < ActiveRecord::Base belongs_to :project end
class Project < ActiveRecord::Base belongs_to :person has_many :tasks end
class Person < ActiveRecord::Base
has_many :projects has_many :tasks, :through => :projects end
DUH! I had always thought that :through would only apply to a model that belongs_to the other two (like a join table).
I should have tried this before going to the forum.
Thanks Rick, Giuseppe
Rick Denatale wrote: