How to assign a has_many/belongs_to relation properly in Rails ActiveRecord?

前端 未结 4 1097
一整个雨季
一整个雨季 2021-01-12 06:46

I have a rails app with articles and author model. If I have an author and a post and want to indicate that the author should be the owner of the article, or that the articl

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 07:24

    Best thing is to use:

    has_and_belongs_to_many
    

    Because, author may have written many article and article can have many authors.

提交回复
热议问题