Rails 3 - has_and_belongs_to_many

前端 未结 3 666
梦谈多话
梦谈多话 2021-01-25 06:34

I have 2 models - Teacher and Subject. A want to connect them via Join table with name Qualification.

It looks like i

3条回答
  •  时光取名叫无心
    2021-01-25 07:16

    You should only use has_and_belongs_to_many if you don't intend to work directly with the join table. In your case, use it if you don't intend to use Qualification itself but only Teacher and Subject and let Active Record do the dirty work. If you have anything to do with the join model, use has_many :through.

    Read more here: Choosing Between has_many :through and has_and_belongs_to_many

提交回复
热议问题