【发布时间】:2014-10-31 02:00:10
【问题描述】:
我知道在 ActiveRecord 中的 has_many :through 关联不适用于 inverse_of,但是我在 Rails Admin gem 中遇到了我的 has many through 模型的问题,当我尝试编辑或创建新资源时,加载该页面导致模板渲染的无限递归。
问题是here
当我尝试删除时
accepts_nested_attributes_for :recipes, allow_destroy: true
成功了,错误消失了。
但当我保留 Accept_nested_attributes_for 并放置时它也有效
has_many :recipes, :through => :recipe_categorizations, :inverse_of => :categories
:inverse_of 结尾。
这怎么可能? inverse_of 对 :through 不可用吗?它的存在会造成任何伤害还是被忽略?
如果有帮助,我正在使用 Rails 4。
【问题讨论】:
标签: ruby-on-rails ruby activerecord associations rails-admin