Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created February 13, 2009 04:05
Show Gist options
  • Save Sutto/63042 to your computer and use it in GitHub Desktop.
Save Sutto/63042 to your computer and use it in GitHub Desktop.
Goal is => Client.first.items... Can do with finder_sql, but want an activerecord way!
class Client < ActiveRecord::Base
has_many :contacts
has_many :tasks, :through => :contacts
has_many :items, :through => :contacts # THIS DOESNT WORK
end
class Contact < ActiveRecord::Base
belongs_to :client
has_many :tasks
has_many :items, :through => :tasks
end
class Task < ActiveRecord::Base
belongs_to :contact
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :task
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment