From 2aeb10413dfa9738d353bd18d99d8378602c1051 Mon Sep 17 00:00:00 2001 From: Caio Formiga Date: Mon, 18 Mar 2013 18:07:30 +0000 Subject: [PATCH] Changing redirect after destroy to referer or article parent --- app/controllers/my_profile/cms_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 46f57dd..a3a27ce 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -182,7 +182,14 @@ class CmsController < MyProfileController if request.post? @article.destroy session[:notice] = _("\"#{@article.name}\" was removed.") - redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent + referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path + if referer and referer[:controller] == 'cms' + redirect_to referer + elsif @article.parent + redirect_to @article.parent.url + else + redirect_to profile.url + end end end -- libgit2 0.21.2