0

I describe how I'm override the resource controller here in another question which I self-answered: Override ActiveAdmin resource controller for only some resources

This has been working without any issue for a year now, but I recently updated ActiveAdmin and now when I delete and hit the function:

def destroy
      if HIPPA_CLASS_ARRAY.include? self.resource_class.name
        if !params[:comment].nil? && !params[:comment].empty?
          @comment=ActiveAdmin::Comment.new(namespace: "admin", author: current_admin_user, resource: resource, body: params[:comment]  )
          @comment.save
          Utils.track_action(request, current_admin_user, "admin_#{params[:action]}", "web", params, false,  resource)
          resource.destroy

          flash[:notice] = "Delete was successful."

    #=> THE FOLLOWING IS THE PROBLEM

          redirect_to { action: "index" } 


        else
           flash[:notice] = "A delete comment can not be blank."
            render :js => 'window.location.reload()'
        end
      else
        super
      end
    end

Out of nowhere I'm now getting:

ActionController::RoutingError (No route matches [DELETE] "/admin/products"):

I've tried:

redirect_to { action: "index" } and return

redirect_to({ action: 'index' }, notice: "Delete was successful.", status: 302) and return

redirect_back fallback_location: { action: "index" } and return

None of these work; the resource gets deleted, but it doesn't redirect to the resource's index anymore.

grimmwerks
  • 491
  • 1
  • 6
  • 21

1 Answers1

0

Might be a change in how your browser is handling redirect from delete method. Try this:

redirect_to { action: 'index', status: 303 }

Mark Fraser
  • 3,160
  • 2
  • 29
  • 48
  • Still not working; since the delete is triggered from either the resource.show (detail) page in active admin or hitting 'delete' in the action on the index page, I created a gist of what is in the log: https://gist.github.com/grimmwerks/bf6bd76d4fffe8a370d9aa4c25f36306 Basically it tries to redirect but it doesn't I even attempted redirect_to({action: 'index', status: 303 }) and return – grimmwerks Oct 30 '17 at 18:25