【发布时间】:2013-03-19 10:37:53
【问题描述】:
我有一个模型叫做游戏。它有两个关联:with :categorytoptens 和 :categorygames:
has_many :categorytoptens
has_many :categories, :through => :categorytoptens, :dependent => :destroy
has_many :categorygames
has_many :categories, :through => :categorygames, :dependent => :destroy
要编辑类别,我将其添加到我的 activeadmin games.rb 文件中:
f.input :categories, :as => :check_boxes, :collection => Category.all, :member_label => :navititle_de
它显示类别模型中所有类别的复选框列表,并将选择保存在 categorygames 中。所以,一切正常。
但是:当我在游戏模型中更改 :categorytoptens 和 :categorygames 的顺序时,类别会保存在 categorytoptens 中:
has_many :categorygames
has_many :categories, :through => :categorygames, :dependent => :destroy
has_many :categorytoptens
has_many :categories, :through => :categorytoptens, :dependent => :destroy
我的问题:
a.) 是否“允许”多个 has_many 具有相同的模型关联?模型关联是否相互“覆盖”? b.) 有没有办法在 activeadmin 中指定要编辑的模型?
非常感谢!
【问题讨论】: