Reform gem を使用して現在のプロジェクトでフォーム オブジェクトを作成していますが、ネストされたフィールドがフォームに表示されません。これが私のコードです:
出荷モデル:
class Shipment < ApplicationRecord
has_one :shipment_detail
end
ShipmentDetail モデル:
class ShipmentDetail < ApplicationRecord
belongs_to :shipment
end
リフォームクラス
class ShipmentForm < Reform::Form
property :shipment_type
property :measure
property :shipment_detail do
property :po_number
property :job_no
end
end
コントローラ
class ShipmentsController < ApplicationController
def new
@shipment = ShipmentForm.new(Shipment.new)
end
end
テンプレート
<%= form_for @shipment, url: shipments_path, method: :post do |f| %>
<%= f.label :shipment_type %><br />
<%= f.text_field :shipment_type %><br /><br />
<%= f.label :measure %><br />
<%= f.text_field :measure %><br /><br />
<%= f.fields_for :shipment_detail do |d| %>
<%= d.label :po_number %><br />
<%= d.text_field :po_number %><br /><br />
<%= d.label :job_no %>
<%= d.text_field :job_no %><br /><br />
<% end %>
<% end %>
フィールドshipment_typeとのみmeasureがフォームに表示され、po_numberとは表示されjob_noません。それらを表示するにはどうすればよいですか?