Is there a way to nest these areas inside each other from different models?
Example:
class Company has_many :employees named_scope :with_employees, :include => :employees end class Employee belongs_to :company belongs_to :spouse named_scope :with_spouse, :include => :spouse end class Spouse has_one :employee end
Is there a good way to find a company, including employees and spouses, such as:
Company.with_employees.with_spouse.find(1)
or I need to define another named_scope in the company:
:with_employees_and_spouse, :include => {:employees => :spouse}
In this far-fetched example, this is not so bad, but the nesting in my application is much deeper, and I would like that I would not have to add the NON-SUSHI code, which redefines the inclusion at each nesting level.
include ruby-on-rails activerecord nested
William jones
source share