Destroy Action Flow - activescaffold/active_scaffold GitHub Wiki

Action 'destroy'

These methods are called in the following order:

  1. delete_authorized_filter called as before_action
    1. delete_authorized? (or the method defined in conf.delete.link.security_method if it's changed) is called to check the permission. If this method returns false, delete_authorized_filter will raise ActiveScaffold::ActionNotAllowed.
  2. destroy
    1. do_destroy
      1. destroy_find_record which uses find_if_allowed to load the record to be edited into @record instance variable, checking :delete permission.
    2. respond_to_action, which will call the corresponding response method for destroy action and the requested format.
      • For HTML request:
        • It will call return_to_main which redirects to main_path_to_return, which defaults to list.
      • For XHR request:
        • It will call do_refresh_list if record was deleted, and refresh_list is enabled in config.delete.
        • It will render destroy.js.erb view

destroy_find_record can be overrided to change how record is find, or do_destroy to change how the record is destroyed, for example enabling a flag to hide the record instead of deleting it.