Protect locked rates from being updated.

* Locked rates will fail to save
* Attempting to save a Locked rates will display an error and reload the
  Rate from the database so the update parameters are thrown away

  #1919
This commit is contained in:
Eric Davis
2009-01-20 11:05:19 -08:00
parent 1cd24e451b
commit a52afb7a2b
2 changed files with 48 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ class RatesController < ApplicationController
@rate = Rate.find(params[:id])
respond_to do |format|
# Locked rates will fail saving here.
if @rate.update_attributes(params[:rate])
flash[:notice] = 'Rate was successfully updated.'
format.html {
@@ -90,6 +91,10 @@ class RatesController < ApplicationController
}
format.xml { head :ok }
else
if @rate.locked?
flash[:error] = "Rate is locked and cannot be edited"
@rate.reload # Removes attribute changes
end
format.html { render :action => "edit" }
format.xml { render :xml => @rate.errors, :status => :unprocessable_entity }
end