Ruby on Rails 3 (3.1) ActiveModel Associations (tableless nested models)

前端 未结 3 1555
不知归路
不知归路 2021-01-12 07:01

How to impliment ActiveModel associations (tableless nested models)?

For example:

book has many chapters

With ActiveRecord I would

3条回答
  •  自闭症患者
    2021-01-12 07:40

    You simply can't do it that way. It is not active record.

    You can check ActiveModel documentation (and source code) at :

    https://github.com/rails/rails/tree/master/activemodel

    I guess you have to do it old fashion way, using an array of chapters and a reference to the book in the chapters.

    Hope this helps!

提交回复
热议问题