Skip to content

Commit

Permalink
Apparently, returning false in before_destroy does not work anymore i…
Browse files Browse the repository at this point in the history
…n rails 5.
  • Loading branch information
xhero committed Jul 19, 2018
1 parent 77371be commit d128a9a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/models/catalogue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/institution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/liturgical_feast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions app/models/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/standard_term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/standard_title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d128a9a

Please sign in to comment.