lib/classiccms/models/base.rb in classiccms-0.2.4.pre vs lib/classiccms/models/base.rb in classiccms-0.3.0
- old
+ new
@@ -7,6 +7,20 @@
include Mongoid::Paranoia
#associations
embeds_many :connections
accepts_nested_attributes_for :connections
+
+ after_destroy :remove_slugs
+ after_destroy :remove_connections
+
+
+ def remove_slugs
+ Slug.where(:document_id => id).destroy
+ end
+ def remove_connections
+ records = Base.where(:'connections.parent_id' => id)
+ records.each do |record|
+ record.connections.where(:parent_id => id).destroy_all
+ end
+ end
end