Unfortunately this mess works: Do you have suggestings for cleaning up this code: I'm trying to use a activerecord to compare two table columns, "needed" and "amount" then update a boolean column, depending on the returned data. Totally breaking do-not-repeat coding.
def update
    @inventory = Inventory.find(params[:id])
    respond_to do |format|
      if @inventory.update_attributes(params[:inventory])
      unless @inventory.needed.nil?
       if @inventory.needed < @inventory.amount then
       @inventory.instock = true
       @inventory.update_attributes(params[:inventory])
       else
       @inventory.instock = false
       @inventory.update_attributes(params[:inventory])
       end
      end
        flash[:notice] = 'Inventory was successfully updated.'
        format.html { redirect_to(@inventory) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @inventory.errors, :status => :unprocessable_entity }
      end
    end
  end
Cheers!