Simple dropdown with selected value and object value set
<select name="user_id" id="user_id"> </select>
<%= select_tag("user_id") %>
<%= select_tag(:user_id) %>
// Generic way
<%= select_tag("user_id", "<option value='0'>Hi</option>".html_safe) %>
// More efficient way
<%= select_tag("user_id", options_for_select([[View, value], [View2, value2]]) ) %>
// Add the selected value of an object
// the selected value has to match the value in the array
<%= select_tag("user_id", options_for_select([[View, value], [View2, value2]], @object.value) ) %>
// Add a data attribute
<%= select_tag("user_id", options_for_select([[View, value], [View2, value2]]), {"data-id" => @object.id } ) %>
//
<%= select_tag "id-of-select",
options_from_collection_for_select(array, "method1_to_call_as_value", "method2_to_call_as_what_to_display"),
class: "form-control" %>