gpt4 book ai didi

ruby-on-rails - 为什么 inverse_of 不支持多态关联?

转载 作者:行者123 更新时间:2023-12-03 14:50:36 25 4
gpt4 key购买 nike

来自 Rails Guide :

There are a few limitations to inverse_of support:

  • They do not work with :through associations.
  • They do not work with polymorphic associations.
  • They do not work with :as associations.
  • For belongs_to associations, has_many inverse associations are ignored.

最佳答案

这不再是事实。 inverse_of由 through、多态和 belongs_to 支持和 has_many协会。但是 through 不支持自动检测和定义 foreign_key 的关联.
https://guides.rubyonrails.org/association_basics.html#bi-directional-associations

关于ruby-on-rails - 为什么 inverse_of 不支持多态关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35104876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com