is it a nested has_many :through association?

I have:
Manager
has_many :companies
has_many :profiles

Company
has_many :managers

Profile
has_many :managers

I want to assign on or more profiles to every Manager-Company

I'm trying:

Manager
has_many :managements
has_many :companies, :through => :managements
has_many :profiles, :through => :managements

Company
has_many :managements
has_many :managers, :through => :managements

Profile
has_many :managers

But the result it seems not as expected.

From what I gather, profiles should be the :through relation!

class Company < ActiveRecord::Base

has_many :profiles

has_many :managers, :through => :profiles

end

class Manager < ActiveRecord::Base

has_many :profiles

has_many :companies, :through => :profiles

end

class Profile < ActiveRecord::Base

belongs_to :company

belongs_to :manager

end

Now, you can assign many profiles for every Manager-Company.

Cheers!

  • Gautam