# File lib/active_scaffold/actions/delete.rb, line 7 def destroy params.delete :destroy_action process_action_link_action(:destroy) do |record| do_destroy end end
# File lib/active_scaffold/actions/delete.rb, line 42 def destroy_find_record @record = find_if_allowed(params[:id], :delete) end
# File lib/active_scaffold/actions/delete.rb, line 15 def destroy_respond_to_html if self.successful? flash[:info] = as_(:deleted_model, :model => @record.to_label) else #error_message_for not available in controller... #flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br) end return_to_main end
# File lib/active_scaffold/actions/delete.rb, line 25 def destroy_respond_to_js do_refresh_list if successful? && active_scaffold_config.delete.refresh_list && !render_parent? render(:action => 'destroy') end
# File lib/active_scaffold/actions/delete.rb, line 34 def destroy_respond_to_json render :text => successful? ? "" : response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status end
# File lib/active_scaffold/actions/delete.rb, line 30 def destroy_respond_to_xml render :xml => successful? ? "" : response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status end
# File lib/active_scaffold/actions/delete.rb, line 38 def destroy_respond_to_yaml render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status end
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 48 def do_destroy @record ||= destroy_find_record begin self.successful = @record.destroy rescue Exception => ex flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label) self.successful = false logger.debug ex.message logger.debug ex.backtrace.join("\n") end end
# File lib/active_scaffold/actions/delete.rb, line 3 def self.included(base) base.before_filter :delete_authorized_filter, :only => [:destroy] end