0

accept_nested_attributes_for を使用した select タグで、多くの明示的な外部キーがあるという問題に直面しています。リストされた関連する値を取得できません。

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%>

関連するすべての単位プレートを select tag にリストしたいと思います。しかし、どういうわけか、この選択タグでそれができるようになりました。

前もって感謝します

4

2 に答える 2