diff --git a/app/models/catalogue.rb b/app/models/catalogue.rb index 5ad4f28f0..59934e351 100644 --- a/app/models/catalogue.rb +++ b/app/models/catalogue.rb @@ -278,7 +278,7 @@ def check_dependencies #{self.referring_catalogues.count} catalogues and #{self.referring_people.count} people #{self.referring_holdings.count} holdings} - return false + throw :abort end end diff --git a/app/models/institution.rb b/app/models/institution.rb index 0b648f444..769b859a9 100644 --- a/app/models/institution.rb +++ b/app/models/institution.rb @@ -249,7 +249,7 @@ def check_dependencies #{self.referring_institutions.count} institutions, #{self.referring_catalogues.count} catalogues and #{self.referring_people.count} people} - return false + throw :abort end end diff --git a/app/models/liturgical_feast.rb b/app/models/liturgical_feast.rb index 1f4fb2786..f9daf4b82 100644 --- a/app/models/liturgical_feast.rb +++ b/app/models/liturgical_feast.rb @@ -70,7 +70,7 @@ def reindex def check_dependencies if (self.referring_sources.count > 0) errors.add :base, "The liturgical fease could not be deleted because it is used" - return false + throw :abort end end diff --git a/app/models/person.rb b/app/models/person.rb index 032c6195d..7c5be59f3 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -257,7 +257,7 @@ def check_dependencies #{self.referring_catalogues.count} catalogues and #{self.referring_people.count} people #{self.referring_holdings.count} holdings} - return false + throw :abort end end diff --git a/app/models/place.rb b/app/models/place.rb index 0107899f8..42f32e236 100644 --- a/app/models/place.rb +++ b/app/models/place.rb @@ -86,7 +86,7 @@ def check_dependencies #{self.referring_catalogues.count} catalogues and #{self.referring_people.count} people #{self.referring_holdings.count} holdings} - return false + throw :abort end end diff --git a/app/models/source.rb b/app/models/source.rb index 3c03f62f2..28f906fff 100644 --- a/app/models/source.rb +++ b/app/models/source.rb @@ -302,19 +302,19 @@ def reindex def check_dependencies if (self.child_sources.count > 0) errors.add :base, "The source could not be deleted because it has #{self.child_sources.count} child source(s)" - return false + throw :abort end if (self.digital_objects.count > 0) errors.add :base, "The source could not be deleted because it has digital objects attached" - return false + throw :abort end if (self.sources.count > 0) errors.add :base, "The source could not be deleted because it refers to #{self.sources.count} source(s)" - return false + throw :abort end if (self.referring_sources.count > 0) errors.add :base, "The source could not be deleted because it has #{self.referring_sources.count} subsequent entry(s)" - return false + throw :abort end end diff --git a/app/models/standard_term.rb b/app/models/standard_term.rb index e4465c688..373180e76 100644 --- a/app/models/standard_term.rb +++ b/app/models/standard_term.rb @@ -76,7 +76,7 @@ def check_dependencies #{self.referring_sources.count} sources, #{self.referring_institutions.count} institutions and #{self.referring_catalogues.count} catalogues} - return false + throw :abort end end diff --git a/app/models/standard_title.rb b/app/models/standard_title.rb index ef155f554..e3251ef1e 100644 --- a/app/models/standard_title.rb +++ b/app/models/standard_title.rb @@ -92,7 +92,7 @@ def reindex def check_dependencies if (self.referring_sources.count > 0) errors.add :base, "The standard title could not be deleted because it is used" - return false + throw :abort end end diff --git a/app/models/work.rb b/app/models/work.rb index 2bc6ec8cd..e307df54e 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -142,7 +142,7 @@ def set_object_fields end def check_dependencies - return false if self.referring_sources.count > 0 + throw :abort if self.referring_sources.count > 0 end def self.get_viaf(str)