Sha256: cbc5d76ccb3bd001fa3f8d1c19414d51e83b34412b7b7a158188b673a4383cfe

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

---
layout:   default
title:    "API: Destroy"
subnav:   api
subtitle: Destroy
---

Note that the `destroy` action is turned off by default. To turn it on, use the core [actions](./core.html#builder_actions) method.

By default, `destroy` simply retrieves the model instance, and calls `ActiveRecord::Base#destroy`. If you'd like to define your own custom deletion semantics, you can set a block that will be called instead of the model's built-in `destroy` method:

    admin_assistant_for Product do |a|
      a.actions << :destroy
      a.destroy do |product|
        product.update_attribute :deleted, true
        product.notify_admins_of_deletion
      end
    end
    
You may also find plugins such as [as\_paranoid] or [acts\_as\_paranoid] useful here. If you're using a plugin such as that, which changes the behavior of `ActiveRecord::Base#destroy`, it means that you will probably not need to customize admin\_assistant in this way.




[acts_as_paranoid]: http://ar-paranoid.rubyforge.org/
[as_paranoid]: http://github.com/semanticart/is_paranoid/tree/master

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
admin_assistant-2.4.0 website/api/destroy.markdown
admin_assistant-2.3.2 website/api/destroy.markdown
admin_assistant-2.3.1 website/api/destroy.markdown
admin_assistant-2.3.0 website/api/destroy.markdown
admin_assistant-2.2.8 website/api/destroy.markdown
admin_assistant-2.2.7 website/api/destroy.markdown
admin_assistant-2.2.6 website/api/destroy.markdown
admin_assistant-2.2.5 website/api/destroy.markdown
admin_assistant-2.2.4 website/api/destroy.markdown
admin_assistant-2.2.3 website/api/destroy.markdown
admin_assistant-2.2.2 website/api/destroy.markdown
admin_assistant-2.2.1 website/api/destroy.markdown
admin_assistant-2.2.0 website/api/destroy.markdown
admin_assistant-2.1.1 website/api/destroy.markdown
admin_assistant-2.1.0 website/api/destroy.markdown
admin_assistant-2.0.1 website/api/destroy.markdown