def destroy(options = {})
      call_hooks 'destroy' do
        options = options.dup
        options[:omit_model_identifiers] ||= {}
        options[:omit_model_identifiers][model_identifier] = self
        self.class.association_columns.each do |name, col|
          delete_candidates = get_attr(name)
          Array(delete_candidates).each do |candidate|
            next if options[:omit_model_identifiers][candidate.model_identifier]
            if col.dependent == :destroy
              candidate.destroy(options)
            elsif col.dependent == :delete
              candidate.delete(options)
            end
          end
        end
        delete
      end
      self
    end
def destroy(options = {})
      call_hooks 'destroy' do
        options = options.dup
        options[:omit_model_identifiers] ||= {}
        options[:omit_model_identifiers][model_identifier] = self
        self.class.association_columns.each do |name, col|
          delete_candidates = get_attr(name)
          Array(delete_candidates).each do |candidate|
            next if options[:omit_model_identifiers][candidate.model_identifier]
            if col.dependent == :destroy
              candidate.destroy(options)
            elsif col.dependent == :delete
              candidate.delete(options)
            end
          end
        end
        delete
      end
      self
    end
def destroy ( options = { } ) call_hooks 'destroy' do options = options . dup options [ :omit_model_identifiers ] ||= { } options [ :omit_model_identifiers ] [ model_identifier ] = self self . class . association_columns . each do | name , col | delete_candidates = get_attr ( name ) Array ( delete_candidates ) . each do | candidate | next if options [ :omit_model_identifiers ] [ candidate . model_identifier ] if col . dependent == :destroy candidate . destroy ( options ) elsif col . dependent == :delete candidate . delete ( options ) end end end delete end self end
Destroys the current object. The difference between delete
 and destroy is that destroy calls <tt>before_delete</tt>
 and <tt>after_delete</tt> hooks. As well, it will cascade
 into related objects, deleting them if they are related
 using <tt>:dependent => :destroy</tt> in the <tt>has_many</tt>
 and <tt>has_one></tt> declarations

 Note: lifecycle hooks are only called when individual objects
 are deleted.
Destroys the current object . The difference between delete and destroy is that destroy calls <tt > before_delete< / tt > and <tt > after_delete< / tt > hooks . As well it will cascade into related objects deleting them if they are related using <tt > : dependent = > : destroy< / tt > in the <tt > has_many< / tt > and <tt > has_one > < / tt > declarations