Rails: Overriding ActiveRecord association method

后端 未结 7 1384
忘了有多久
忘了有多久 2020-12-05 02:21

Is there a way to override one of the methods provided by an ActiveRecord association?

Say for example I have the following typical polymorphic has_many :through ass

7条回答
  •  时光取名叫无心
    2020-12-05 02:58

    Rails guides documents about overriding the added methods directly.

    OP's issue with overriding << probably is the only exception to this, for which follow the top answer. But it wouldn't work for has_one's = assignment method or getter methods.

提交回复
热议问题