Sha256: 0c72ec6a989403479c7da1697544a48dd0ecbbd4565e969ca6c340a87cb41752

Contents?: true

Size: 814 Bytes

Versions: 8

Compression:

Stored size: 814 Bytes

Contents

require 'mongoid'
Mongoid::Fields.option :input do |model, field, value|
  #model.validates_presence_of field if value
end
Mongoid::Fields.option :options 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
  include Mongoid::MultiParameterAttributes

  #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

8 entries across 8 versions & 1 rubygems

Version Path
classiccms-0.6.0 lib/classiccms/models/base.rb
classiccms-0.5.17 lib/classiccms/models/base.rb
classiccms-0.5.16 lib/classiccms/models/base.rb
classiccms-0.5.15 lib/classiccms/models/base.rb
classiccms-0.5.14 lib/classiccms/models/base.rb
classiccms-0.5.13 lib/classiccms/models/base.rb
classiccms-0.5.12 lib/classiccms/models/base.rb
classiccms-0.5.11 lib/classiccms/models/base.rb