ActiveRecord::HasManyThroughNestedAssociationsAreReadonly Error in Rails Admin

两盒软妹~` 提交于 2019-12-04 11:37:00

This happens because your association is nested, meaning (from rails source) : A through association is nested if there would be more than one join table... which is your case here.

Apparently a workaround (I didn't test) is telling Vendor it doesn’t need to autosave the association.

has_many :categories, :through => :products, :autosave => false

You can mark the association as readonly and rails_admin will then not generate the category fields in the form for vendor:

has_many :categories, -> { readonly }, through: :products

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!