Skip to content

Commit bca3a85

Browse files
authored
Merge pull request #16 from serge1peshcoff/fix-crashing-on-associates-restore
Fixes crashing when reverting a model linked to non-existent associate
2 parents ad52d8a + 90780fd commit bca3a85

4 files changed

Lines changed: 9 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: "Невозможно восстановить: эта модель ссылается на другую модель, которой не существует."

config/locales/history_rollback.zh_cn.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ zh_cn:
88
field: "字段"
99
rollback: "还原"
1010
view_changes: "查看"
11+
rollback_destroy: "Rolled back newly-created record by destroying it."
12+
rollback_success: "Rolled back changes to this record."
13+
rollback_impossible: "Couldn't rollback. Sorry."
14+
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."

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)