I'm trying to figure out a way to use the has_many :through option to
aggregate collections in a specific way. Here's an example of the
issue I'm trying to address:
create_table :companies do |t|
create_table :employees do |t|
class Employee < ActiveRecord::Base
class Company < ActiveRecord::Base
has_many :companies, :class_name => 'Company', :foreign_key =>
has_many :all_employees, :through => :children_companies, :source
A company may own other companies (has_many :companies). Each company
has its own set of employees (has_many :employees). What I'd like to
be able to do is have a search-able collection of all employees for a
company (including all the employees at each child company). However,
has_many :all_employees only gives me the employees of the child
companies, but not the companies proper employees.
If I use the :finder_sql option I lose finder_in_collection on the
association which is what I'm really after.
Any advice would be immensely appreciated.