Sha256: 296d9820dacb02ab2537f7641778913b2dbd9d2161cb7d050c480971585c9011

Contents?: true

Size: 562 Bytes

Versions: 18

Compression:

Stored size: 562 Bytes

Contents

require 'mongoid'

class Base
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Versioning
  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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
classiccms-0.5.6 lib/classiccms/models/base.rb
classiccms-0.5.5 lib/classiccms/models/base.rb
classiccms-0.5.2 lib/classiccms/models/base.rb
classiccms-0.5.1 lib/classiccms/models/base.rb
classiccms-0.5.0 lib/classiccms/models/base.rb
classiccms-0.4.2 lib/classiccms/models/base.rb
classiccms-0.4.1 lib/classiccms/models/base.rb
classiccms-0.4.0 lib/classiccms/models/base.rb
classiccms-0.3.9 lib/classiccms/models/base.rb
classiccms-0.3.8 lib/classiccms/models/base.rb
classiccms-0.3.7 lib/classiccms/models/base.rb
classiccms-0.3.6 lib/classiccms/models/base.rb
classiccms-0.3.5 lib/classiccms/models/base.rb
classiccms-0.3.4 lib/classiccms/models/base.rb
classiccms-0.3.3 lib/classiccms/models/base.rb
classiccms-0.3.2 lib/classiccms/models/base.rb
classiccms-0.3.1 lib/classiccms/models/base.rb
classiccms-0.3.0 lib/classiccms/models/base.rb