title: Rails 3 - How to change attribute in controller before update save?
body: <p>So, i have form that updates a record in the database.  In my controllers <code>update</code> action i want to change a value to something if another one of the values is <code>Estimate</code>.  Maybe this will make more sense...this is what i'm trying to do.</p>
  
  <pre><code>def update
      @invoice = Invoice.find(params[:id])
      if @invoice.update_attributes(params[:invoice])
          if@invoice.status == "Estimate"
              # if the value of status is Estimate then change the
              # value of estimate_sent_date to the current timestamp
          end
          redirect_to invoices_path
      else
          render 'edit'
      end
  end
  </code></pre>
  
  <p>The only values of the form that i'm concerned with are <code>status</code> and <code>estimate_sent_date</code>.  Mostly, i'm just not sure how to change the value of <code>estimate_sent_date</code> and save that record.</p>
  
  <p>Also, should i save everything and then do a separate call to save the <code>estimate_sent_date</code> or just save it all at once?  I guess i could change the value of <code>estimate_sent_date</code> before calling <code>if @invoice.update_attributes(params[:invoice])</code>, couldn't i?</p>
  
  <p>Thanks for the help!</p>