我在另一个我自己回答的问题中描述了我如何覆盖资源控制器:Override ActiveAdmin resource controller for only some resources
这一年来一直没有任何问题,但我最近更新了ActiveAdmin,现在当我删除并点击该功能时:
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
突然之间,我现在得到了:
ActionController::RoutingError (No route matches [DELETE] "/admin/products"):
我试过了:
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
这些都不起作用;资源被删除,但它不再重定向到资源的索引。
答案 0 :(得分:0)
可能会改变浏览器处理delete
方法重定向的方式。试试这个:
redirect_to { action: 'index', status: 303 }