0
在选择标签面对一个问题与accepts_nested_attributes_for与有许多和明确的外键。我无法获得列出的关联值。accepts_nested_attributes嵌套形式和选择字段
Models
class PlantPlate < Plate
has_many :unit_plates, :foreign_key => 'parent_id', :dependent => :destroy
accepts_nested_attributes_for :unit_plates, :allow_destroy => true
end
class UnitPlate < Plate
belongs_to :plant_plate, :foreign_key => 'parent_id'
end
View
/plant_plates/_form.html.erb
<%= nested_form_for([ :admin, @plant_plate ]) do |f| %>
<%= f.fields_for :unit_plates do |unit_plate| %>
<%= unit_plate.collection_select :parent_id, UnitPlate.all,:id,:name %>
<%end
<%end%>
我想列出所有相关的单元板中选择标签。但不知何故,现在能够用这个选择标签做到这一点。
在此先感谢
我使用嵌套形式的宝石,所以我需要这个nested_form_for – AnkitG
你可以请分享一些关于错误引发的更多细节吗?或者您的development.log中的一些输出,而没有更多代码很难提供帮助 –