view.erb
<select ng-model="integration.connector_one">
<%=options_for_select(connectors, connectors[0])%>
</select>
Produces:
<select ng-model="integration.connector_one" class="ng-pristine ng-valid">
<option value="? undefined:undefined ?"></option>
<option value="1" selected="selected">Shopify</option>
<option value="8">Spreadsheet</option>
<option value="9">Pardot</option>
<option value="10">Spreadsheet</option>
<option value="11">Spreadsheet</option>
<option value="12">Pardot</option>
</select>
Connectors is:
[["Shopify", 1], ["Spreadsheet", 8], ["Pardot", 9], ["Spreadsheet ", 10], ["Spreadsheet ", 11], ["Pardot", 12]]
How can i prevent the undefined option from being created?
The second argument to options_for_select is the optional selected parameter, which is either a single value, or in the case of multiple select elements, and array of values to be selected. In this case, it's looking for options with values Shopify and 1 and marking those selected. Since it's not finding Shopify (as a value), you're getting the undefined element.
Change connectors[0] to connectors[0][1] to just pass the value of the first option.