Sha256: ba5eaacc0fa3c0794e0adc9ac3c052f8db14f6b36ad2b0899f2a2a79c718e43c
Contents?: true
Size: 1.63 KB
Versions: 5
Compression:
Stored size: 1.63 KB
Contents
module RailsAdmin module Config module Actions class Delete < RailsAdmin::Config::Actions::Base RailsAdmin::Config::Actions.register(self) register_instance_option :member do true end register_instance_option :route_fragment do 'delete' end register_instance_option :http_methods do [:get, :delete] end register_instance_option :authorization_key do :destroy end register_instance_option :controller do Proc.new do if request.get? # DELETE respond_to do |format| format.html { render @action.template_name } format.js { render @action.template_name, :layout => false } end elsif request.delete? # DESTROY redirect_path = nil @auditing_adapter && @auditing_adapter.delete_object("Destroyed #{@model_config.with(:object => @object).object_label}", @object, @abstract_model, _current_user) if @object.destroy flash[:success] = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.delete.done")) redirect_path = index_path else flash[:error] = t("admin.flash.error", :name => @model_config.label, :action => t("admin.actions.delete.done")) redirect_path = back_or_index end redirect_to redirect_path end end end register_instance_option :link_icon do 'icon-remove' end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems