-
Notifications
You must be signed in to change notification settings - Fork 330
API: Delete
activescaffold edited this page Sep 15, 2010
·
11 revisions
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
The action link used to tie the Delete action to the List table. See API: Action Link for the options on this setting.
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