Method: Model#destroy
- Defined in:
- lib/yodel/models/core/model/model.rb
#destroy ⇒ Object
Destroys all records which are instances of this model, removes a reference to the model from the parent site, and repeats for any child models of the model.
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/yodel/models/core/model/model.rb', line 416 def destroy # remove this model from the model tree parent.try(:remove_descendant, self) mixins.each {|mixin| mixin.remove_descendant(self)} # destroy model subclasses, and all record instances children.each(&:destroy) all.each(&:destroy) # remove the association between the site and this model site.model_types.delete(name.underscore.pluralize) site.model_plural_names.delete(name) site.save # remove any remaining indexes indexes.each do |name| RecordIndex.remove_index_for_model(self, name) end record_fields.each do |name, field| RecordIndex.remove_index_for_field(self, field) if field.index? end # destroy the model record super end |