Class: Markable::Mark
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Markable::Mark
- Defined in:
- lib/models/mark.rb
Class Method Summary collapse
-
.delete_orphans ⇒ Number
Delete orphan marks.
Class Method Details
.delete_orphans ⇒ Number
Delete orphan marks
Marks are deleted when marker or markable record is destroyed. However, in some circumstances, some marks may reference non existing records (for instance if the record has been deleted - not destroyed).
Note: this method is not efficient but this should not be a problem as it should be used as a maintenance operation only.
17 18 19 20 21 22 23 |
# File 'lib/models/mark.rb', line 17 def self.delete_orphans Markable::Mark.all.delete_if { |mark| mark.marker && mark.markable }.each { |orphan| Markable::Mark.delete_all orphan.attributes }.count end |