Rails 4 many to many association not working

后端 未结 2 593
遇见更好的自我
遇见更好的自我 2021-01-06 10:17

Ruby on rails newbie here. Trying to create a starter blog app and having trouble with many to many association between my models.

I have 2 models - Post, Category t

2条回答
  •  不知归路
    2021-01-06 10:59

    Further to the first answer, you need to put associations in your join model (CategoriesPosts) like this:

    Class CategoriesPosts  < ActiveRecord::Base
        belongs_to :category
        belongs_to :post
    End
    

提交回复
热议问题