Sha256: 8ab2516a842d64a34838fea96437974731331318451c68f60d13b60442bbc725
Contents?: true
Size: 887 Bytes
Versions: 4
Compression:
Stored size: 887 Bytes
Contents
module Markable class Mark < ActiveRecord::Base belongs_to :markable, :polymorphic => true belongs_to :marker, :polymorphic => true attr_accessible :markable_id, :markable_type, :marker_id, :marker_type, :mark # 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. # # @return [Number] Deleted orphan marks count def self.delete_orphans Markable::Mark.all.delete_if { |mark| mark.marker && mark.markable }.each { |orphan| Markable::Mark.delete_all orphan.attributes }.count end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
markable-0.1.4 | lib/models/mark.rb |
markable-0.1.3 | lib/models/mark.rb |
markable-0.1.2 | lib/models/mark.rb |
markable-0.1.1 | lib/models/mark.rb |