Created
January 25, 2011 15:35
-
-
Save brianjlandau/795075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| rescue_from ActiveRecord::StaleObjectError do |exception| | |
| respond_to do |format| | |
| format.html { | |
| correct_stale_record_version | |
| stale_record_recovery_action | |
| } | |
| format.xml { head :conflict } | |
| format.json { head :conflict } | |
| end | |
| end | |
| protected | |
| def stale_record_recovery_action | |
| flash.now[:error] = "Another user has made a change to that record "+ | |
| "since you accessed the edit form." | |
| render :edit, :status => :conflict | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DestinationsController < ApplicationController | |
| protected | |
| def correct_stale_record_version | |
| @destination.reload.attributes = params[:destination].reject do |attrb, value| | |
| attrb.to_sym == :lock_version | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment