在Ruby on Rails中,我想查找城市中的雇主。 假设模型设置如下:
City
has_many :suburbs
has_many :households, :through => suburbs
has_many :people, :through => suburbs
Suburb
has_many :households
has_many people, :through => households
belongs_to :city
Household
has_many :people
belongs_to :suburb
People
belongs_to :household
belongs_to :employer
Employer
has_many :people
我觉得我想要某种雇主加入some_city.people,但我不知道该怎么做。如果人员直接属于城市,我可以加入Employer到人员中,其中city_id是某个值,但我想找到没有这种直接连接的相同数据,我有点迷失。
谢谢。