title: How can I get a ruby on rails select dropdown to automatically contain the proper information?
body: <p>I have an object called a device that is associated with a customer.  Once the customer orders a device, then the factory assigns the device to the customer, and the customer registers the device, and communication between the device and the rest of its associated functions can begin.</p>
  
  <p>When I display the edit page to the factory administrator via the following:</p>
  
  <pre><code>  &lt;%= form_for @device do |f| %&gt;
      &lt;%= render 'fields', f: f %&gt;
  </code></pre>
  
  <p>The 'customer' field, which is itself defined in its own table, appears properly as a select dropdown.  However, the default value for that select is not the currently assigned customer, but is just the current customer in the list.  Is there a way using the above default rendering scheme to make the select dropdown use the current value for the device?</p>
  
  <p>I've tried several variations on the theme:</p>
  
  <pre><code>  &lt;%= form_for @device do |f| %&gt;
      &lt;%= render 'fields', f: f %&gt;
      &lt;%= f.select :customer, options_for_select(@customers.each{|p| [p.name, p.id]}, @device.customer.name)%&gt;
  </code></pre>
  
  <p>but these approaches just result in one gigantic dropdown that runs the entire width of the screen and, even then, does not show the appropriate default value.  In addition, the f.select just shows the object ID of the customer, rather than the name itself.</p>