title: Ruby on Rails: How to update a record's attributes except one?
body: <p>In my Rails app I have an <code>update</code> action that <code>users</code> can use to update their profile.</p>
  
  <p>The tricky thing I want to achieve is that if a user enters a <strong>new</strong> email address and saves it, that email address won't get saved to the <code>email</code> database field straightaway, but rather to a database field called <code>new_email</code>. The field <code>email</code> should remain untouched (at least until the <code>user</code> has confirmed that email address later on).</p>
  
  <pre><code>def update
    current_email = @user.email
    new_email = params[:user][:email].downcase.to_s
    if @user.update_attributes(params[:user])    
      if new_email != current_email
        @user.change_email(current_email, new_email)     
        flash[:success] = "Profile updated. Please confirm your new email by clicking on the link that we've sent you."
      else
        flash[:success] = "Profile updated."
      end
      redirect_to edit_user_path(@user)
    else
      render :edit
    end
  end
  </code></pre>
  
  <p><strong>User model:</strong></p>
  
  <pre><code>def change_email(old_email, new_email)
    self.new_email = new_email.downcase 
    self.email = old_email
    self.send_email_confirmation_link
  end 
  </code></pre>
  
  <p>The function above <em>kind of</em> works but is hard to test and <em>doesn't feel right</em>. Is there a smoother way to achieve this?</p>
  
  <p>Thanks for any help.</p>