title: Update attributes for User only if attributes have changed
body: <p>The original, happily working version of my project looked like this:</p>
  
  <p>1)  User fills out form (new action) and hits submit (create action)</p>
  
  <p>2)  User is redirected to their edit page (edit action uses an edit_id created by model, not Rails auto-gen id), which shows the info user had already submitted</p>
  
  <p>3)      User can choose to change info (update action) and re-submit</p>
  
  <p>In this version, even if the user changes nothing in the edit page and submits, the page will still flash a success alert. </p>
  
  <p>From a database perspective, I don’t really care, because since the form is prefilled with the user’s info, the update_attributes method is just overriding old info with the same info.</p>
  
  <p>From a user perspective though, it's annoying, so I want to ensure that the info is only updated and the success alert flashed only if the user actually changes something. </p>
  
  <p>I thought this would be really easy, changing the old code from this:</p>
  
  <pre><code>def update
    @request = Request.find_by_edit_id(params[:edit_id])
    if @request.update_attributes(request_params) 
      flash[:success] = true
      redirect_to edit_request_path(@request.edit_id)
    else
      render 'edit'
    end
  end
  </code></pre>
  
  <p>And adding one additional component to the "if" like this:</p>
  
  <pre><code>def update
    @request = Request.find_by_edit_id(params[:edit_id])
    if @request.update_attributes(request_params) &amp;&amp; @request.changed?
      flash[:success] = true
      redirect_to edit_request_path(@request.edit_id)
    else
      render 'edit'
    end
  end
  </code></pre>
  
  <p>But this doesn’t work. Now what happens is that, on the edit page, if I don’t change any info and hit submit, nothing happens (which is great), but if I DO change info and hit submit, still nothing happens (which is bad). What am I doing wrong?</p>
  
  <p>Note: I initially thought it was an order of operations error, so I made it a nested if, with first if @request.update_attributes, and second if @request.changed, but this didn't work either... </p>