title: Updating object belongs_to association creates new objects
body: <p>I have an Event object with a <code>belongs_to</code> association to <code>location</code>:</p>
  
  <pre><code>class Event &lt; ActiveRecord::Base
    belongs_to :location
    accepts_nested_attributes_for :location  
  end
  </code></pre>
  
  <p>In my Event form I use nested attributes to display the location form. Relevant bit for location form from <code>events/_form.html.erb</code>:</p>
  
  <pre><code>&lt;%= f.fields_for :location do |lf| %&gt;  
    &lt;%= f.label 'Location', :class =&gt; 'control-label' %&gt;
    &lt;%= lf.text_field :name  %&gt;
    &lt;%= lf.text_field :address %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I create a new Event as follows:</p>
  
  <pre><code>  def new
      @event = Event.new
      @event.build_location
    end
  </code></pre>
  
  <p>However, when I edit the location of this newly created record, the location record does not get edited, instead a new location record gets inserted in the database.</p>
  
  <p>My question is, how do I make sure that upon editing a location (from the parent Event form), it will update the attributes belonging to the location object instead of creating a new Location object.</p>