RFID オブジェクトと Device オブジェクトを関連付けるためのフォームがあります。フォームを送信すると、rfid の ID が自動的に渡されます。options_from_collection_for_select で選択されたデバイスの ID を渡すにはどうすればよいですか?
フォームのコードは次のとおりです。
<br/>
<div class="well">
<%= form_for(@rfid) do |f| %>
<table class="table table-bordered">
<tr>
<th>RFID Tag #</th>
<td>
<%= f.label(:@rfid, @rfid.rfid_tag) %>
<%= f.hidden_field :rfid, :value => @rfid %>
</td>
</tr>
<tr>
<th>Device Name</th>
<td>
<%= f.select :device, options_from_collection_for_select(Device.order(:name).where("rfid_tag IS NULL"), "id", "name_or_alternative", @device) %>
</td>
</tr>
</table>
<%= link_to "Link Device", { :controller => :devices, :action => :assign_rfid_to_device, :device => @device }, :class => "btn btn-primary" %>
<% end %>