Skip to content
activescaffold edited this page Sep 15, 2010 · 11 revisions

formats

Active scaffold supports html, js, json, yaml, and xml formats by default. If you need to add another mime type for the delete action you can do it here. The format is then added to the default formats.

Examples:

# Add a format
config.delete.formats << :pdf

link global local

The action link used to tie the Delete action to the List table. See API: Action Link for the options on this setting.

Actions Before Delete

If you need to perform some operation before deleting a record, you can override the do_destroy method. After performing your operations, simply call super to return to the ActiveScaffold delete operations.

Example:
In this example we want to log the destroy to a log table.

class ProspectsController < ApplicationController
  def do_destroy
    record = Prospect.find_by_id(params[:id])
    log = Log.create(:description => "Deleted prospect #{record.name}", :created_by => current_user.name)
    log.save
    super
  end
end
Clone this wiki locally