Skip to content

Commit 3df252b

Browse files
Fixes crashing when reverting a model linked to non-existent associate
1 parent 13e7e8d commit 3df252b

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

config/locales/history_rollback.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ en:
1212
rollback_success: "Rolled back changes to this record."
1313
rollback_impossible: "Couldn't rollback. Sorry."
1414
version_not_found: "Version does not exist."
15+
rollback_violates_foreign_key: "Couldn't rollback: this model links to another model, which doesn't exists."

config/locales/history_rollback.ru.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ru:
1212
rollback_success: "Изменения данной версии восстановлены."
1313
rollback_impossible: "Невозможно восстановить. Извините."
1414
version_not_found: "Данная версия не существует."
15+
rollback_violates_foreign_key: "Невозможно восстановить: эта модель ссылается на другую модель, которой не существует."

lib/rails_admin_history_rollback/config/actions/history_index.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class HistoryIndex < Base
5656
rescue ActiveRecord::RecordNotFound
5757
flash[:error] = t 'admin.history_rollback.version_not_found'
5858
redirect_to :action => :history_index
59+
rescue ActiveRecord::InvalidForeignKey
60+
flash[:error] = t 'admin.history_rollback.rollback_violates_foreign_key'
5961
end
6062

6163
redirect_to :action => :history_index

0 commit comments

Comments
 (0)