I have a software table, which has 4 fields; id, vendor, title and edition. I need a drop down box in my licenses form which will show every record like this: vendor – title – edition, but then only save the id of the chosen record to the database. I’m currently using a text box where the user can just enter the id of the software which will be saved to the database. here is my current form:
<%= form_for(@licenses) do |f| %>
<div class="well">
<%= f.label 'Software' %><br />
<%= f.text_field :software_id %>
<%= f.label 'Quantity' %><br />
<%= f.text_field :amount %>
<%= f.submit 'add'%>
</div>
<% end %>
I need to change the software text field into a drop down box, sorry if this is vague, i’ve not had anything to do with drop down boxes before.
Checkout collection_select for populating drop box
create a method in softwarer model like
and in view