Find sub sub records

Hi everyone, I have the following problem, maybe someone can help me
figure out what to do.

To simplify my situation, I'm going to make an example of what I need,
this is not the real app structure.

Let's suppose we have three models, Library, Author, Book.

Manager
has_and_belongs_to_many :area_managers

AreaManager
has_and_belongs_to_many :managers
has_many :employees

Employee
belongs_to :area_manager

Given a manager, I'd like to find all the employees under its area
managers in a single query.

Hi everyone, I have the following problem, maybe someone can help me
figure out what to do.

To simplify my situation, I'm going to make an example of what I need,
this is not the real app structure.

Let's suppose we have three models, Library, Author, Book.

Manager
has_and_belongs_to_many :area_managers

I think this will work, though I am not quite sure given this a habtm
rather than has_many. Include here
has_many :employees, :through => :area_managers

AreaManager
has_and_belongs_to_many :managers
has_many :employees

Employee
belongs_to :area_manager

Given a manager, I'd like to find all the employees under its area
managers in a single query.

@employees = @manager.employees

Colin

Hi friend

u can try this oneā€¦There are three tables :Library,Author,book

Class Library <ActiveRecord::Base
has_many :Authors
has_many :Books
end

Class Author <ActiveRecord::Base

belongs_to :library
has_many :books
end

Class Book <ActiveRecord::Base
belongs_to :library
belongs_to :author
end