1

これをメインフォームに持っています

    <%= simple_nested_form_for @customer_bill do |f| %>

        <%= f.label :customer_id %>
        <%= f.collection_select :customer_id, Customer.all,:id,:name, {:prompt => "Select Customer"}, :style => 'width:205px;' %><br />

        <%= f.link_to_add "Add", :customer_bill_line_items,  :locals => {:text_1 => :customer_id} %>
    /* rest of code */
    <%end%>

そして、私はこれを私のcustomer_bill_line_itemsに持っています

<%= f.hidden_field :customer_id, :value => :text_1 %>
/*rest of code*/

しかし、選択した顧客IDを部分的にキャプチャできません。非表示フィールドの値が 0 になります。この問題を解決する方法についてのガイダンスは素晴らしいでしょう。前もって感謝します

4

1 に答える 1

1
<%= f.hidden_field :customer_id, :value => :text_1 %>

整数フィールドのcustomer_idを推測しており、:valueを文字列であるtext_1として設定しています。

text_1の値が整数の場合、text_1.to_i

于 2012-11-12T20:28:20.510 に答える