module ActiveScaffold::Actions::Delete
Public Class Methods
included(base)
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 3 def self.included(base) base.before_action :delete_authorized_filter, :only => [:destroy] end
Public Instance Methods
destroy()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 7 def destroy params.delete :destroy_action process_action_link_action(:destroy) do |record| do_destroy(record) end end
Protected Instance Methods
delete_ignore?(record = nil)
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 61 def delete_ignore?(record = nil) (nested? && nested.readonly?) || !authorized_for?(:crud_type => :delete) end
destroy_find_record()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 34 def destroy_find_record @record = find_if_allowed(params[:id], :delete) end
destroy_respond_to_html()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 16 def destroy_respond_to_html flash[:info] = as_(:deleted_model, :model => ERB::Util.h(@record.to_label)) if successful? return_to_main end
destroy_respond_to_js()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 21 def destroy_respond_to_js do_refresh_list if successful? && active_scaffold_config.delete.refresh_list && !render_parent? render(:action => 'destroy') end
destroy_respond_to_json()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 30 def destroy_respond_to_json render :json => successful? ? '' : response_object, :only => active_scaffold_config.list.columns.visible_columns_names, :status => response_status end
destroy_respond_to_xml()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 26 def destroy_respond_to_xml render :xml => successful? ? '' : response_object, :only => active_scaffold_config.list.columns.visible_columns_names, :status => response_status end
do_destroy(record)
click to toggle source
A simple method to handle the actual destroying of a record May be overridden to customize the behavior
# File lib/active_scaffold/actions/delete.rb, line 40 def do_destroy(record) record ||= destroy_find_record begin self.successful = record.destroy rescue StandardError => exception flash[:warning] = as_(:cant_destroy_record, :record => ERB::Util.h(record.to_label)) self.successful = false logger.warn do "\n\n#{exception.class} (#{exception.message}):\n " + Rails.backtrace_cleaner.clean(exception.backtrace).join("\n ") + "\n\n" end end end
Private Instance Methods
destroy_formats()
click to toggle source
# File lib/active_scaffold/actions/delete.rb, line 72 def destroy_formats (default_formats + active_scaffold_config.formats + active_scaffold_config.delete.formats).uniq end