Sha256: 47d860e9e2c4462cd27982694b382e5c059a725b75b79699d349dce2b825b2aa

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require 'mongoid'
Mongoid::Fields.option :input do |model, field, value|
  #model.validates_presence_of field if value
end
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.delete_all(:document_id => id)
  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

1 entries across 1 versions & 1 rubygems

Version Path
classiccms-0.5.7 lib/classiccms/models/base.rb